6

I am using Matlab for ubuntu R2014a and I am not able to run a code because I get the following error

/usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:version 'GLIBCXX_3.4.21' not found

when I run:

$ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBC_2.3
GLIBC_2.2.5
GLIBC_2.14
GLIBC_2.4
GLIBC_2.18
GLIBC_2.3.4
GLIBC_2.17
GLIBC_2.3.2
GLIBCXX_DEBUG_MESSAGE_LENGTH

Here you can see that I have GLIBCXX_3.4.21 but then also I get the error!

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83

4 Answers4

8

Actually I figured out what was wrong, as my system was GCC 5.2.1,

the file /usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6 was designed for GCC 4.4.X so Matlab was actually picking the wrong file. I just made a symbolic link to my system's libstdc++.so.6 using this on terminal -

ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6

Cbhihe
  • 2,761
  • 3
  • 24
  • 47
5

It looks like /usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6 is missing the glibc version and not /usr/lib/x86_64-linux-gnu/libstdc++.so.6. Now Matlab first tries the libstdc++.so.6 in the Matlab path and fails.

From a post from mathworks the following should work to start matlab with the system libstdc++.so.6

LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6" matlab
Eliah Kagan
  • 117,780
Thomas
  • 6,223
  • The link is dead, and when clicking through to the Google Groups, that's dead as well (no results found). Solution still works though. – Adriaan Mar 22 '19 at 15:16
0

The link from @Thomas is available in the WayBack machine but this didn't work for me as I'm missing GLIBCXX_3.4.22 which judging by strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC is actually missing. I fixed this by following these steps (also here):

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6
0

I had the same error when running executables from matlab's system() function. The executable was dependent on a different libstdc++ than matlab had available. For both matlab R2022a and R2022b on Ubuntu 22.04, I simply linked matlab's shortcut to the system's libc++ rather than the one that ships with matlab. Perhaps this is an edge case that doesn't match the OP's from years ago, but it's one I've run into with each version of matlab and had to fix multiple times, each time leading me to this Q&A.

mike@poincare:~$ ls -l /usr/local/MATLAB/R2022b/sys/os/glnxa64/libstdc++*
lrwxrwxrwx 1 root root      19 May 13 15:31 /usr/local/MATLAB/R2022b/sys/os/glnxa64/libstdc++.so.6 -> libstdc++.so.6.0.28*
-r-xr-xr-x 1 root root 1907456 May 13 15:31 /usr/local/MATLAB/R2022b/sys/os/glnxa64/libstdc++.so.6.0.28
mike@poincare:~$ ls -l /usr/lib/x86_64-linux-gnu/libstdc++*
lrwxrwxrwx 1 root root      19 May 13 07:11 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 -> libstdc++.so.6.0.30
-rw-r--r-- 1 root root 2252096 May 13 07:11 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30
mike@poincare:~$ sudo rm /usr/local/MATLAB/R2022b/sys/os/glnxa64/libstdc++.so.6
mike@poincare:~$ sudo ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30 /usr/local/MATLAB/R2022b/sys/os/glnxa64/libstdc++.so.6

Now, matlab loads the libstdc++.so.6 from my system rather than from its own version, and things run fine.

mightypile
  • 1,192