1
我目前正在使用C中的CPLEX API編寫MEX文件來解決線性編程問題。不幸的是,當我嘗試編譯時遇到了「架構x86_64中找不到的符號」問題,而我不知道如何解決它。「架構x86_64找不到的符號」對於使用CPLEX API的MEX文件C
的一些基本信息:
- 我可以編譯10.7.2
- 我使用的是Mac OSX上
yprime.c
,並且不使用CPLEX API - 其他MEX文件,我使用MATLAB 2011B GCC 4.2包含在XCode 4.2中。
- 我已經應用XCode 4.2 Patch for MATLAB
我將不勝感激任何意見的人可能有。我在下面列出詳細的錯誤報告。
-> 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.
我必須在mex命令中包含-lcplex作爲標誌嗎? 我確信我正確鏈接了頭文件,因爲當我在CPLEX API中不使用正確的變量類型時,編譯器會吐出錯誤。這讓我覺得我也必須鏈接一個庫,儘管readme.html文件沒有爲C API指定一個庫。 對不起,如果問題很愚蠢 - 我只是非常新的。 – 2012-03-17 23:13:36