MATLAB GCC version compatibility fix
Matlab requires compatible compilers to run compiled code and even to run itself. Trying to use Matlab on a non-supported just-released OS version can sometimes encounter difficulty. libc, libstdc++, or libgfortran incompatible with Matlab and cause failure to run MEX code. The workaround below assumes Linux.
Example error messages:
MATLAB/R*/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found (myfun.mexa64)
Workaround by having the system libraries take priority by using environment variable LD_PRELOAD.
Find the system libstdc++:
find /usr -name libstdc++.so.6
Suppose “/usr/lib64/libstdc++.so.6”.
LD_PRELOAD=/usr/lib64/libstdc++.so.6 matlab