I couldn't compile my c code with the shared library generated by matlab from m files. How can I resolve this?
조회 수: 11 (최근 30일)
이전 댓글 표시
Compile option
""" gcc -O3 -I/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/extern/include/ -L/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/extern/lib/glnxa64/ -L/for_testing -ltest main.c -o main
/tmp/ccip5bsu.o:
In function `main':
main.c:(.text.startup+0xa6): undefined reference to `mxCreateDoubleMatrix_730_proxy'
main.c:(.text.startup+0xba): undefined reference to `mxCreateDoubleMatrix_730_proxy'
main.c:(.text.startup+0xc5): undefined reference to `mxGetPr_proxy'
main.c:(.text.startup+0x125): undefined reference to `mxGetPr_proxy'
main.c:(.text.startup+0x1a9): undefined reference to `mlxMyMult'
main.c:(.text.startup+0x1b3): undefined reference to `mxGetPr_proxy'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
댓글 수: 0
답변 (2개)
Philip Caplan
2015년 4월 14일
This looks like a linker error where the implementations of "mxCreateDoubleMatrix", "mxGetPr", etc. were not found. Is the command you posted complete? I see the path was specified but the only library linked against was "test". Please try adding "-lmx -lmclmcrrt" at the end of your compiling command.
If that does not help, please provide some more details about your operating system and MATLAB version.
댓글 수: 1
K R S Nandhan
2021년 3월 23일
I have similar error but my code is in c++.
g++ -g -o main main.cpp
/usr/bin/ld: /tmp/ccn43UqG.o: in function `rt_atan2d_snf(double, double)':
/home/nandhan/games/test/rcamcoder.cpp:32: undefined reference to `rtNaN'
/usr/bin/ld: /tmp/ccn43UqG.o: in function `rt_powd_snf(double, double)':
/home/nandhan/games/test/rcamcoder.cpp:70: undefined reference to `rtNaN'
/usr/bin/ld: /home/nandhan/games/test/rcamcoder.cpp:81: undefined reference to `rtInf'
/usr/bin/ld: /home/nandhan/games/test/rcamcoder.cpp:88: undefined reference to `rtInf'
/usr/bin/ld: /home/nandhan/games/test/rcamcoder.cpp:103: undefined reference to `rtNaN'
collect2: error: ld returned 1 exit status
참고 항목
카테고리
Help Center 및 File Exchange에서 C Shared Library Integration에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!