error while compiling Matlab mex file on Ubuntu 11.04 with Matlab R2011a

风格不统一 提交于 2019-12-11 08:44:50

问题


I am trying to compile a shared library which will call MATLAB function on Ubuntu 11.04. Like the command:

mcc - B cpplib:libStepCluster StepCluster.m

Get the following error.

/usr/lib/i38-linux-gnu/i686-linux-gnu/4.5.2/cc1plus: /usr/local/MATLAB/R2010a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl_c.so.2) 
/usr/lib/i38-linux-gnu/i686-linux-gnu/4.5.2/cc1plus: /usr/local/MATLAB/R2010a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl_c.so.2) 
/usr/lib/i38-linux-gnu/i686-linux-gnu/4.5.2/cc1plus: /usr/local/MATLAB/R2010a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /usr/lib/libppl.so.7) 
/usr/lib/i38-linux-gnu/i686-linux-gnu/4.5.2/cc1plus: /usr/local/MATLAB/R2010a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libppl.so.7) 
/usr/lib/i38-linux-gnu/i686-linux-gnu/4.5.2/cc1plus: /usr/local/MATLAB/R2010a/sys/os/glnx86/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by /usr/lib/libgmpxx.so.4)

I konw the code works fine with Ubuntu 10.10, and upgraded to Ubuntu 11.04. Then the problem comes out. What is the problem and how to resolve it without too much pain?


回答1:


MatLab R2011a Compile Error Solution.

Download and install GCC-4.4

Use command: mbuild -setup

Choose option 1 and then you will get a file locate in /usr/local/MATLAB/R2011a/bin/mbuildopts.sh

Search the file and replace all the compiler option with gcc-4.4

Then compile it, it should be fine!




回答2:


The root is GLIBCXX_3.4.14' not found. Looking a similar SO question: GLIBCXX versions and @ninjalj answer, it appears you have a linker problem:

Use readelf -a and objdump -x to inspect ELF files in preference to strings.

Actually, all the GLIBCXX_* versions don't apply to the entire library, but to each symbol (symbol versioning, see DSO-howto). So you can have e.g: std::char_traits<wchar_t>::eq@@GLIBCXX_3.4.5 and std::ios_base::Init::~Init()@@GLIBCXX_3.4 on the same library file.

The fact that your program needs GLIBCXX_3.4.9 probably means that it has been linked against a symbol that has been introduced/has changed semantics on GLIBCXX_3.4.9.




回答3:


I tried Eric Chu's answer but this is the only thing that worked for me:

sudo ln -s /usr/lib/libstdc++.so.6 {MATLABROOT}/sys/os/{architecture}/libstdc++.so.6

You will want to backup the file first.



来源:https://stackoverflow.com/questions/7639666/error-while-compiling-matlab-mex-file-on-ubuntu-11-04-with-matlab-r2011a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!