Version GLIBCXX_3.4.11 not found (required by buildW.mexglx)


I am trying to compile a c++ ubuntu project via matlab here. When I am trying to use it after the compilation with make command, I am getting the following error:

Invalid MEX-file
 //local/MATLAB/R2011a/bin/glnx86/../../sys/os/glnx86/ version
`GLIBCXX_3.4.11' not found (required by

I am not familiar with those processes, so I couldnt understand the several proposed solutions like that. What is exactly libstdc++ and GLIBCXX and how can I solve the problem?

I am trying to fix the problem using the proposed link from nkjt:

export LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH

However, due to lack of unix shell knowledge I don’t understand what to put in the command. I am have locate libstdc++ .a and .so file which is in gcc folder /usr/lib/gcc/i686-linux-gnu/4.6 and I am trying the following:

 export LD_LIBRARY_PATH=/usr/lib/gcc/i686-linux-gnu/4.6:$LD_LIBRARY_PATH

However, my matlab error still exist. I am using Ubuntu 12.04 version with gcc 4.6 and matlab r2011a.

EDIT: I ve updated the matlab version to r2012a the problem still the same. I also tried the following:

sudo ln -s /usr/lib/cc/i686-linux-gnu/4.6/ 

I got failed to create the file the file already exists.

The output of usr/lib/ | grep GLIBC:


How can I ensure that I ve defined the right version of libstdc++?


Matlab (and a ton of other commercial programs like Steam, Mathematica, etc.) ships its own version of the


The problem is that when you start matlab, it loads this one first, and since it is loaded, this version is used to resolve all dynamic loader dependencies.

You compiled with your system GCC and linked to your system’s libstdc++, which is newer. The resulting binary then requests symbols of a certain (newer) version and the loader does not find them in the already loaded version (i.e. Matlab’s).

There are two ways to solve this:

* Delete/rename Matlab’s and symlink your system’s version to the exact same name:

    sudo rm /usr/local/MATLAB/R2011a/bin/glnx86/../../sys/os/glnx86/
    sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/local/MATLAB/R2011a/bin/glnx86/../../sys/os/glnx86/

* Delete Matlab's version and let your OS's loader pick up the system's `libstdc++`:

    sudo rm /usr/local/MATLAB/R2011a/bin/glnx86/../../sys/os/glnx86/

* Use the environment variable `LD_PRELOAD` to "inject" the system's version of `libstdc++` into the execution environment before anything else, which prevents the old Matlab version to be loaded:
    LD_PRELOAD=/usr/lib/x86_64-linux-gnu/ matlab
  1. Install the GCC version Matlab expects and modify the Mex building options (or use update-alternatives) to use that instead of the system’s GCC.

Note that for 1-3, you may need to mess with additional libraries like, in the same way.

The reason that using the new version works is because of the symbol versioning scheme employed in libstdc++ internally (hence also the detailed error message mentioning the version). A similar "fix" needs to be done for Steam on e.g. Arch Linux, where several system libraries Steam uses are linked to the newer libstdc++.

The real solution is for Matlab not to ship the and instead use the OS provided version.

Answered By – rubenvb

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published