version `GLIBCXX_3.4.21' not found

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!


Solution 1:

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

Solution 2:

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