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

3.2k views Asked by At

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?

3

There are 3 answers

0
Eric Chu On

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!

0
dgorissen On

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.

1
Elpezmuerto On

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.