How does Matlab load shared libraries for a MEX files?

3 views (last 30 days)
Hi, I am have problem Mex compiling and running. I wrote a Mex files using opencv built with libstdc++.so.6.0.18. My Matlab2012a have libstdc++.so.6.0.13. I compiled successfully, but cannot run successfully. This is a very common problem for those using MEX. There is a solution from some people that make a symbolic link libstdc++.so in matlab bin folder with the newer version of libstdc++ which is libstdc++.so.6.0.18 (as in http://stackoverflow.com/questions/9959306/how-to-tell-mex-to-link-with-the-libstdc-so-6-in-usr-lib-instead-of-the-one-i). In order to do this, I need to sudo permission. However, I run my code on server, and I don't have sudo rights. I want to ask if there is any workaround. I try to set LD_LIBRARY_PATH with first entry containing the newer version. However, it still raises errors:
>> mex_video2images('diving01.avi', 'imgs', 'png') Invalid MEX-file '/hpctmp/a0081742/workspace/mytoolbox/mex_video2images.mexa64': /nfs/app1/common/matlab/R2012a/bin/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/svu/a0081742/local/lib/libopencv_highgui.so.2.4)
Clearly, setting LD_LIBRARY_PATH won't affects Matlab loading libstdc++.so. It still load libstdc++.so in the matlab bin. My LD_LIBRARY_PATH at that time is:
/app1/centos6.3/gnu/gcc-4.8.2/lib64:/nfs/app1/common/matlab/R2012a/sys/os/glnxa64:/nfs/app1/common/matlab/R2012a/bin/glnxa64:/nfs/app1/common/matlab/R2012a/extern/lib/glnxa64:/nfs/app1/common/matlab/R2012a/runtime/glnxa64:/nfs/app1/common/matlab/R2012a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/nfs/app1/common/matlab/R2012a/sys/java/jre/glnxa64/jre/lib/amd64/server:/nfs/app1/common/matlab/R2012a/sys/java/jre/glnxa64/jre/lib/amd64:/app1/common/matlab/R2012a/toolbox/NAG/mex.a64:/app1/centos6.3/gnu/gcc-4.8.2/lib64:/app1/centos6.3/gnu/gcc-4.8.2/lib:/home/svu/a0081742/local/lib64:/home/svu/a0081742/local/lib:/app1/centos6.3/gnu/gcc-4.8.2:/app1/common/lsf7/perf/1.2/linux-x86_64/lib:/app1/common/lsf7/perf/ego/1.2/linux-x86_64/lib:/app1/common/lsf7/perf/lsf/7.0/linux-x86_64/lib:/app1/common/lsf7/7.0/linux2.6-glibc2.3-x86_64/lib:/app1/common/lsf7/1.2/linux2.6-glibc2.3-x86_64/lib:/app1/common/Apps/gurobi562/linux64/lib:/app1/centos6.3/gnu/gcc-4.8.2/lib64:/app1/centos6.3/gnu/gcc-4.8.2/lib64::/app1/common/maple/maple16/bin.X86_64_LINUX/X8664SSE2:/app1/common/maple/maple16/bin.X86_64_LINUX:
In /nfs/app1/common/matlab/R2012a/sys/os/glnxa64, it also have a version libstdc++.so. But Matlab does not load, it comes to load the third entry in LD_LIBRARY_PATH. I have bigger doubt about how Matlab load the libraries for MEX files. Does it have it own loader or it uses linux Gnu loader (I am using Centos). Hope to have your responses. Thank you all, @@@@@@@@@@@@

Answers (0)

Community Treasure Hunt

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

Start Hunting!