MATLAB: Do I receive a link error from libstdc++.so when I try to compile the application with MATLAB Compiler 4.1 (R14SP1)

externalgcc-3.3glibcpp_3_2MATLAB Compilerunresolved

When I compile the magicsquare example using gcc 3.3, the compilation fails with link errors such as:
undefined reference to `operator delete(void*)@GLIBCPP_3.2'

Best Answer

The undefined references may result from compiling with gcc 3.3.3 and linking with the libstdc++ provided with that gcc installation.
The libraries distributed with MATLAB and the MATLAB Component Runtime (MCR) are dependent on symbols in the gcc 3.2.3 version of libstdc++. This version of libstdc++ is shipped with both MATLAB and the MCR.
To work around this issue, try the following:
1. Modify the CLIBS line (line 88) of the script ~/.MATLAB/R14/bin/mbuildopts.sh so that it appears as follows:
CLIBS="$RPATH $MLIBS -lm -L$TMW_ROOT/sys/os/glnx86 -lstdc++"
2. Create a symbolic link from libstdc++.so.5 to libstdc++.so in $MATLAB/sys/os/glnx86 (where $MATLAB = the MATLAB root directory on your machine) as follows:
For example, if MATLAB is installed in /usr/matlab
cd /usr/matlab/sys/os/glnx86
ln -s libstdc++.so.5 libstdc++.so
Note: This solution has not officially been tested by MathWorks.