matlab 엔진을 사용하는 예제 engdemo.cpp
을 컴파일하고 실행하도록 Eclipse를 구성하려고합니다. matlab에 엔진을 사용하는 C++ 프로그램 이클립스를 컴파일
make all
Building target: matlabEngine
Invoking: GCC C++ Linker
g++ -L/usr/local/MATLAB/R2011a/bin/glnx86 -Xlinker -rpath-link -Xlinker /usr/local/MATLAB/R2011a/bin/glnx86 -o"matlabEngine" ./engdemo.o -leng -lm -lmat -lmex -lut
/usr/bin/ld: ./engdemo.o: undefined reference to symbol 'mxDestroyArray'
/usr/bin/ld: note: 'mxDestroyArray' is defined in DSO /usr/local/MATLAB/R2011a/bin/glnx86/libmx.so so try adding it to the linker command line
/usr/local/MATLAB/R2011a/bin/glnx86/libmx.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [matlabEngine] Errore 1
그래서 그것을 실행할 수 있습니다.
g++ -c -I/usr/local/MATLAB/R2011a/extern/include -I/usr/local/MATLAB/R2011a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/local/MATLAB/R2011a/extern/include/cpp -I/usr/local/MATLAB/R2011a/extern/include -DGLNX86 -DGCC -DMX_COMPAT_32 -O -DNDEBUG "engdemo.cpp"
g++ -O -o "engdemo" engdemo.o -Wl,-rpath-link,/usr/local/MATLAB/R2011a/bin/glnx86 -L/usr/local/MATLAB/R2011a/bin/glnx86 -leng -lmx -lm
하지만 이클립스에서 컴파일해야합니다. 도움이 되었습니까?
libmx가 Eclipse 명령 행에서 누락 된 것 같습니다. 해당 라이브러리를 추가 했습니까? – Rolle
@Rolle, 링커가 .so의 이름과 라이브러리의 경로를 어떻게 알고 있다고 생각합니까? – stanri