1

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?

Amro
  • 123,847
  • 25
  • 243
  • 454
Eric Chu
  • 21
  • 1
  • 3
  • Please format your answer properly, it will help in answering – Elpezmuerto Oct 03 '11 at 19:43
  • @EricChu: Take a look at these discussions and let us know if it helped (I haven't tested any of the solutions myself): http://forums.opensuse.org/english/get-technical-help-here/applications/443229-after-11-3-upgrade-matlab-compiler-fails-because-gcc.html, https://bbs.archlinux.org/viewtopic.php?id=86809 – Amro Oct 04 '11 at 03:30
  • Appreciating for the formatting... – Eric Chu Oct 04 '11 at 15:24
  • Actually. I found the problem later. The ubuntu11.04 comes with gcc-4.5, however, the default compiler for MatlabR2011a is gcc-4.3.4. I searched a little bit found Matlab2011 still support gcc-4.4. I downloaded and installed it. Use command mbuild -setup configured the matlab with the supported gcc-4.4. Recompile and the problem is gone. Thanks for the reply. – Eric Chu Oct 04 '11 at 15:37
  • @EricChu: you should post that as a solution (it is perfectly fine to accept your own answer). btw, you can see the list of supported compilers here: http://www.mathworks.com/support/compilers/R2011b/glnxa64.html – Amro Oct 05 '11 at 23:14
  • related question: http://stackoverflow.com/questions/7495154/mex-files-and-gcc-4-6-0 – Amro Oct 05 '11 at 23:15

3 Answers3

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!

Eric Chu
  • 21
  • 1
  • 3
0

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.

Community
  • 1
  • 1
Elpezmuerto
  • 5,391
  • 20
  • 65
  • 79
  • Thanks for the reply. I configured the matlab for the correct gcc compiler. And the problem is gone. I didn't get a chance to try your solution. Still thanks. – Eric Chu Oct 04 '11 at 15:40
0

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.

Community
  • 1
  • 1
dgorissen
  • 6,207
  • 3
  • 43
  • 52