Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
664 views
in Technique[技术] by (71.8m points)

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

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

/usr/lib/gcc/i686-linux-gnu/4.7/cc1plus:
/usr/local/MATLAB/R2012a/sys/os/glnx86/libstdc++.so.6:
version `GLIBCXX_3.4.15' not found
(required by /usr/lib/i386-linux-gnu/libppl_c.so.4)

/usr/lib/gcc/i686-linux-gnu/4.7/cc1plus:
/usr/local/MATLAB/R2012a/sys/os/glnx86/libstdc++.so.6:
version `GLIBCXX_3.4.15' not found
(required by /usr/lib/i386-linux-gnu/libppl.so.9)

By strings /usr/lib/i386-linux-gnu/libstdc++.so.6 | grep 'GLIBCXX' I confirm that this libstdc++.so.6 has that version string. I reviewed mexopts.sh and modified the variable $RPATH and $MLIBS in that script, but it doesn't work. So if I don't use symbolic link, where can I config the path of the libstdc++.so.6 that mex uses? Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

/usr/lib/gcc/i686-linux-gnu/4.7/cc1plus: /usr/local/MATLAB/R2012a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.15' not found

The problem is that when you are building with mex, it puts -L/usr/local/MATLAB/R2012a/sys/os/glnx86 on the link line, and so the linker picks up libstdc++.so from there.

If you can't convince mex to prepend -L/usr/lib/i386-linux-gnu first, then I think your only other choice is to remove /usr/local/MATLAB/R2012a/sys/os/glnx86/libstdc++.so (just rename it to e.g. libstdc++.so.bak).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...