필터 지우기
필터 지우기

How do I control the order of linking arguments in MEX?

조회 수: 1 (최근 30일)
Samarth
Samarth 2015년 2월 7일
편집: Samarth 2015년 2월 9일
Does anyone know how I can get mex to maintain the linking order of library files? For example, I am trying to compile a mex file with a static and a shared library:
mex -n -largeArrayDims -I${PROJECT_SOURCE_DIR}/include -L${PROJECT_SOURCE_DIR}/lib -ldataloop /usr/local/cuda/lib64/libcudart.so -outdir ${PROJECT_SOURCE_DIR}/bin ${PROJECT_SOURCE_DIR}/src/mex_dataloop.cpp
However, the 3 command lines produced are
Building with 'g++'.
Warning: You are using gcc version '4.8.2'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
Warning: You are using gcc version '4.8.2-19ubuntu1)'. The version of gcc is not supported. The version currently supported with MEX is '4.7.x'. For a list of currently supported compilers see: http://www.mathworks.com/support/compilers/current_release.
/usr/bin/g++ -c -D_GNU_SOURCE -DMATLAB_MEX_FILE -I/home/samarth/Documents/sandbox/mex_dataloop/build/..//include -I"/usr/local/MATLAB/R2014b/extern/include" -I"/usr/local/MATLAB/R2014b/simulink/include" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -O -DNDEBUG /home/samarth/Documents/sandbox/mex_dataloop/build/..//src/mex_dataloop.cpp -o /tmp/mex_289352688213564_29302/mex_dataloop.o
/usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2014b/extern/lib/glnxa64/mexFunction.map" /tmp/mex_289352688213564_29302/mex_dataloop.o /usr/local/cuda/lib64/libcudart.so -ldataloop -L/home/samarth/Documents/sandbox/mex_dataloop/build/..//lib -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L"/usr/local/MATLAB/R2014b/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o /home/samarth/Documents/sandbox/mex_dataloop/build/..//bin/mex_dataloop.mexa64
rm -f /tmp/mex_289352688213564_29302/mex_dataloop.o
MEX completed successfully.
Note how in the linking phase (i.e. second command line),
/usr/local/cuda/lib64/libcudart.so -ldataloop
appears before
-L/home/samarth/Documents/sandbox/mex_dataloop/build/..//lib
which causes the linking to fail. I want
-L/home/samarth/Documents/sandbox/mex_dataloop/build/..//lib -ldataloop /usr/local/cuda/lib64/libcudart.so
but cannot figure out how to acheive that through mex. Thanks!

채택된 답변

Samarth
Samarth 2015년 2월 9일
편집: Samarth 2015년 2월 9일
Couldn't figure out how change the order, so I solved the problem by compiling libdataloop to be shared.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by