Mex compilation cannot find the library for linking?
Show older comments
Hello, I am building a Mex file and here is my linking command:
algosPath = '../../../../';
algosPath = '/home/myname/Algos/'
openCVIncludePath = ['-I' algosPath 'ThirdParty/OpenCV-2.4.1/include' ]
openCVLibPath = ['-L' algosPath 'ThirdParty/OpenCV-2.4.1/lib/Linux/' ]
ippIncludePath = ['-I' algosPath 'ThirdParty/Intel/IPP61/Linux/include' ]
ippLibPath1 = ['-L' algosPath 'ThirdParty/Intel/IPP61/Linux/lib' ]
ippLibPath2 = ['-L' algosPath 'ThirdParty/Intel/IPP61/Linux/sharedlib' ]
CC_3RD_PARTY_LIBS = ['-lopencv_highgui.so'];
mex('-v',openCVIncludePath, ippIncludePath, openCVLibPath, CC_3RD_PARTY_LIBS, ippLibPath1, ippLibPath2, 'StrelMex.cpp')
I got the error:
-> g++ -c -I/home/myname/Algos/ThirdParty/OpenCV-2.4.1/include -I/home/myname/Algos/ThirdParty/Intel/IPP61/Linux/include -I/usr/local/MATLAB/R2013a/extern/include -I/usr/local/MATLAB/R2013a/simulink/include -DMATLAB_MEX_FILE -ansi -D_GNU_SOURCE -fPIC -fno-omit-frame-pointer -pthread -DMX_COMPAT_32 -O -DNDEBUG "StrelMex.cpp"
-> g++ -O -pthread -shared -Wl,--version-script,/usr/local/MATLAB/R2013a/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o "StrelMex.mexa64" StrelMex.o -L/home/myname/Algos/ThirdParty/OpenCV-2.4.1/lib/Linux/ -llopencv_highgui.so -L/home/myname/Algos/ThirdParty/Intel/IPP61/Linux/lib -L/home/myname/Algos/ThirdParty/Intel/IPP61/Linux/sharedlib -Wl,-rpath-link,/usr/local/MATLAB/R2013a/bin/glnxa64 -L/usr/local/MATLAB/R2013a/bin/glnxa64 -lmx -lmex -lmat -lm
/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -llopencv_highgui.so
collect2: ld returned 1 exit status
mex: link of ' "StrelMex.mexa64"' failed.
I have checked the folder: /home/myname/Algos/ThirdParty/OpenCV-2.4.1/lib/Linux/ and found that the lib libopencv_highgui.so existing there.
I don't what I miss here. Also the path /usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld is pointing to no where in my computer.
Could you please help?
Thank you.
Answers (1)
Walter Roberson
on 15 Sep 2017
I suspect
CC_3RD_PARTY_LIBS = ['-lopencv_highgui.so'];
should be
CC_3RD_PARTY_LIBS = ['opencv_highgui.so'];
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!