How to tell mex to link with the libstdc++.so.6 in /usr/lib instead of the one in the MATLAB directory?

后端 未结 8 1216
半阙折子戏
半阙折子戏 2020-12-01 12:55

Now mex in MATLAB 2012a only officially supports gcc 4.4.6 but I want to use gcc 4.7 at my own risk. Now If I compile something with mex directly, it will complain that

相关标签:
8条回答
  • 2020-12-01 13:55

    If you don't have root access then you can try,
    LD_PRELOAD='path/to/libstdc++.so.6.0.21' matlab

    0 讨论(0)
  • 2020-12-01 13:56

    I was not able to find where my libstdc++.so.6 is, so I was not able to fully test the solution given by geek_girl. However, a modification of th1rdey3's worked. I ran in the matlab console:

    setenv('LD_LIBRARY_PATH', 'usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64:/usr/local/MATLAB/R2011a/bin/glnxa64:/usr/lib/boost_1_54_0/libs/regex/build/gcc');
    

    This is the value I use for 'LD_LIBRARY_PATH' when compiling my C++ code in Eclipse (I am not using mex files, instead I create an executable of my C++ code in Eclipse and later run it from matlab shell). In my case the value of 'LD_LIBRARY_PATH' is that long because my C++ code uses boost's regex, matlab libraries (libmat, libmx and so on), GSL library and Armadillo. If you don't use all these libraries, setenv('LD_LIBRARY_PATH','') should be enough, I guess.

    0 讨论(0)
提交回复
热议问题