Compiler Errors for a MEX file using the CPLEX C API

2 次查看(过去 30 天)
I'm currently writing a MEX file that uses the CPLEX API in C to solve linear programming problems. Unfortunately, I run into a "symbol(s) not found for architecture x86_64" problem when I attempt to compile. I am including a verbose error report below.
Some more information:
- I can compile yprime.c - I am using MATLAB 2011b on Mac OSX 10.7.2 - I am compiling with GCC 4.2 included in XCode 4.2. - I already applied the XCode patch in (<http://www.mathworks.com/support/solutions/en/data/1-FR6LXJ/>)
I would greatly appreciate any advice you might have!
-> mexopts.sh sourced from directory (DIR = $PREF_DIR)
FILE = /Users/berk/.matlab/R2011b/mexopts.sh
----------------------------------------------------------------
-> MATLAB = /Applications/MATLAB_R2011b.app
-> CC = llvm-gcc-4.2
-> CC flags:
CFLAGS = -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions -Wall
CDEBUGFLAGS = -g
COPTIMFLAGS = -O2 -DNDEBUG
CLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> CXX = llvm-g++-4.2
-> CXX flags:
CXXFLAGS = -fno-common -no-cpp-precomp -fexceptions -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5
CXXDEBUGFLAGS = -g
CXXOPTIMFLAGS = -O2 -DNDEBUG
CXXLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
arguments = -DMX_COMPAT_32
-> FC = gfortran
-> FC flags:
FFLAGS = -fexceptions -m64 -fbackslash
FDEBUGFLAGS = -g
FOPTIMFLAGS = -O
FLIBS = -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -L -lgfortran -L -lgfortranbegin
arguments = -DMX_COMPAT_32
-> LD = llvm-gcc-4.2
-> Link flags:
LDFLAGS = -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map
LDDEBUGFLAGS = -g
LDOPTIMFLAGS = -O
LDEXTENSION = .mexmaci64
arguments =
-> LDCXX =
-> Link flags:
LDCXXFLAGS =
LDCXXDEBUGFLAGS =
LDCXXOPTIMFLAGS =
LDCXXEXTENSION =
arguments =
----------------------------------------------------------------
-> llvm-gcc-4.2 -c -I/Users/berk/Applications/IBM/ILOG/CPLEX_Studio_Academic123/cplex/include/ilcplex/ -I/Applications/MATLAB_R2011b.app/extern/include -I/Applications/MATLAB_R2011b.app/simulink/include -DMATLAB_MEX_FILE -fno-common -no-cpp-precomp -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -fexceptions -Wall -DMX_COMPAT_32 -O2 -DNDEBUG "addcutsmx.c"
addcutsmx.c:488:4: warning: "/*" within comment
addcutsmx.c:37: warning: 'free_and_null' declared 'static' but never defined
addcutsmx.c:38: warning: 'usage' declared 'static' but never defined
-> llvm-gcc-4.2 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2011b.app/extern/lib/maci64/mexFunction.map -o "addcutsmx.mexmaci64" addcutsmx.o -L/Applications/MATLAB_R2011b.app/bin/maci64 -lmx -lmex -lmat -lstdc++
Undefined symbols for architecture x86_64:
"_CPXLopenCPLEX", referenced from:
_mexFunction in addcutsmx.o
"_CPXLcreateprob", referenced from:
_mexFunction in addcutsmx.o
"_CPXLchgobjsen", referenced from:
_mexFunction in addcutsmx.o
"_CPXLnewcols", referenced from:
_mexFunction in addcutsmx.o
"_CPXLaddrows", referenced from:
_mexFunction in addcutsmx.o
"_CPXLlpopt", referenced from:
_mexFunction in addcutsmx.o
"_CPXLsolution", referenced from:
_mexFunction in addcutsmx.o
"_CPXLgetbase", referenced from:
_mexFunction in addcutsmx.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
mex: link of ' "addcutsmx.mexmaci64"' failed.
Error using mex (line 206)
Unable to complete successfully.

采纳的回答

Ken Atwell
Ken Atwell 2012-3-30
It looks like MEX can't find the CPLEX libraries. Try adding:
-L<path/to/cplex/libs> -l<name_of_library>
when you invoke MEX.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by