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

后端 未结 8 1267
半阙折子戏
半阙折子戏 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:42

    On Matlab R2015b, I first relinked libstdc++.so.6 and then edited .matlab7rc.sh as described above by @lindelof. On my desktop, from terminal:

    locate libstdc++.so.6
    

    In my case, the system library is located in /usr/lib64. Then

    cd /usr/local/matlab/sys/os/glnxa64
    mv libstdc++.so.6 libstdc++.so.6.bak
    ln -s /usr/lib64/libstc++.so.6 libstc++.so.6
    cd /usr/local/src/matlab/bin/glnxa64/
    mv libstdc++.so.6 libstdc++.so.6.bak
    ln -s /usr/lib64/libstc++.so.6 libstc++.so.6
    

    Then edit .matlab7rc.sh in {matlabroot}/bin. Delete in the same directory any mexopts.sh file. Restart Matlab. MEX your file from scratch (this will build a new mexopts.sh file with the new settings. Run it from Matlab console.

提交回复
热议问题