Trouble compiling c++ examples that read .mat files on osx
조회 수: 1 (최근 30일)
이전 댓글 표시
When compiling one of the examples for reading mat files in c++ I get the following result
bash-3.2$ gcc -I /Applications/MATLAB_R2012a.app/extern/include/ matdgns.c
matdgns.c: In function 'diagnose':
matdgns.c:81: warning: format '%d' expects type 'int', but argument 3 has type 'mwSize'
matdgns.c:81: warning: format '%d' expects type 'int', but argument 3 has type 'mwSize'
matdgns.c:112: warning: format '%d' expects type 'int', but argument 3 has type 'mwSize'
matdgns.c:112: warning: format '%d' expects type 'int', but argument 3 has type 'mwSize'
Undefined symbols for architecture x86_64:
"_matOpen", referenced from:
_diagnose in ccAC9eU9.o
"_matGetDir", referenced from:
_diagnose in ccAC9eU9.o
"_mxFree", referenced from:
_diagnose in ccAC9eU9.o
"_matClose", referenced from:
_diagnose in ccAC9eU9.o
"_matGetNextVariableInfo", referenced from:
_diagnose in ccAC9eU9.o
"_mxGetNumberOfDimensions_730", referenced from:
_diagnose in ccAC9eU9.o
"_mxIsFromGlobalWS", referenced from:
_diagnose in ccAC9eU9.o
"_mxDestroyArray", referenced from:
_diagnose in ccAC9eU9.o
"_matGetNextVariable", referenced from:
_diagnose in ccAC9eU9.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
So it looks like the linker just can't find the libmat.dylib library, but I have set up my environment as described in http://www.mathworks.com/help/techdoc/matlab_external/f19027.html so the command "echo $DYLD_LIBRARY_PATH" results in
bash-3.2$ echo $DYLD_LIBRARY_PATH
/Applications/MATLAB_R2012a.app/bin/maci64:/Applications/MATLAB_R2012a.app/sys/os/maci64:/Applications/MATLAB_R2012a.app/bin/maci64:
Can anyone see what I'm missing?
댓글 수: 0
채택된 답변
Ken Atwell
2012년 6월 3일
The doc you indicated assumes you are building from within MATLAB, using the MEX command. You're building with GCC from the command-line. You need to include the MATLAB libraries on your command line (MEX does this for you). Include the following in your gcc invocation:
-lmx -lmex -lmat
This may be enough. If not, trying building your engine application with "mex" inside MATLAB. Use the -v switch to get verbose output, which will help you determine the exact gcc command line(s) needed to build outside of MATLAB.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!