在进行这个实验中,通过c++调用matlab中自己编写的函数(是通过将该函数在matlab中mcc编译成.so,然后c++中调用这个.so的方式),报错记录总结。
实验环境:Ubuntu 12.04.5 64bit, gcc 4.6, matlab 2012a。
<span style="font-size:12px;">$ g++ -o main -I. -L. -L/opt/MATLAB/R2012a/runtime/glnxa64 main.cpp -lmyFunc
/usr/bin/ld: warning: libmwmclmcrrt.so.7.17, needed by ./libmyFunc.so, not found (try using -rpath or -rpath-link)
/tmp/cci4LSpW.o: In function `main':
main.cpp:(.text+0x18b): undefined reference to `mclTerminateApplication_proxy'
/tmp/cci4LSpW.o: In function `mwException::mwException()':
main.cpp:(.text._ZN11mwExceptionC2Ev[_ZN11mwExceptionC5Ev]+0x41): undefined reference to `mclcppCreateError'
/tmp/cci4LSpW.o: In function `mwException::mwException(char const*)':
main.cpp:(.text._ZN11mwExceptionC2EPKc[_ZN11mwExceptionC5EPKc]+0x55): undefined reference to `mclcppCreateError'
/tmp/cci4LSpW.o: In function `mwException::mwException(error_info*, bool)':
main.cpp:(.text._ZN11mwExceptionC2EP10error_infob[_ZN11mwExceptionC5EP10error_infob]+0x5e): undefined reference to `ref_count_obj_addref'
main.cpp:(.text._ZN11mwExceptionC2EP10error_infob[_ZN11mwExceptionC5EP10error_infob]+0x75): undefined reference to `mclcppCreateError'
/tmp/cci4LSpW.o: In function `mwException::~mwException()':
main.cpp:(.text._ZN11mwExceptionD2Ev[_ZN11mwExceptionD5Ev]+0x33): undefined reference to `ref_count_obj_release'
/tmp/cci4LSpW.o: In function `mwException::what() const':
main.cpp:(.text._ZNK11mwException4whatEv[mwException::what() const]+0x25): undefined reference to `error_info_get_message'
/tmp/cci4LSpW.o: In function `mwException::raise_error()':
main.cpp:(.text._ZN11mwException11raise_errorEv[mwException::raise_error()]+0x1b): undefined reference to `mclcppGetLastError'
/tmp/cci4LSpW.o: In function `mwArray::mwArray(unsigned long, unsigned long, mxClassID, mxComplexity)':
main.cpp:(.text._ZN7mwArrayC2Emm9mxClassID12mxComplexity[_ZN7mwArrayC5Emm9mxClassID12mxComplexity]+0x4f): undefined reference to `mclGetMatrix'
/tmp/cci4LSpW.o: In function `mwArray::~mwArray()':
main.cpp:(.text._ZN7mwArrayD2Ev[_ZN7mwArrayD5Ev]+0x23): undefined reference to `ref_count_obj_release'
/tmp/cci4LSpW.o: In function `mw