I couldn't compile my c code with the shared library generated by matlab from m files. How can I resolve this?
9 次查看(过去 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!