问题描述
现在 MATLAB 2012a 中的 mex 仅正式支持 gcc 4.4.6,但我想自担风险使用 gcc 4.7.现在如果我直接用 mex 编译一些东西,它会抱怨
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)
通过 strings/usr/lib/i386-linux-gnu/libstdc++.so.6 |grep 'GLIBCXX'
我确认这个 libstdc++.so.6
有那个版本字符串.我查看了 mexopts.sh
并修改了该脚本中的变量 $RPATH
和 $MLIBS
,但它不起作用.所以如果我不使用符号链接,我在哪里可以配置 mex 使用的 libstdc++.so.6
的路径?谢谢.
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.
推荐答案
您需要创建一个到 gcc 4.7 库的符号链接,以便 matlab 知道使用它.类似的东西:
You need to create a symbolic link to the gcc 4.7 library so matlab knows to use it. Something like:
ln -s {/path/to/file-name} {link-name}
如果您不想使用符号链接,则只需在启动 matlab 的终端中定义此路径:
If you don't want to use symbolic links, then just define this path in a terminal from which you launch matlab:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libstdc++.so.6
./matlab
这篇关于如何告诉 mex 与/usr/lib 中的 libstdc++.so.6 链接而不是 MATLAB 目录中的链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!