MATLAB: Do I receive a ‘GLIBCXX not found’ error on the Redhat or CentOS Linux machine

centosglibcxxlibstdc++linuxMATLABredhat

Why do I receive a dependency error when installing MATLAB Connector on my Redhat or CentOS Linux machine?
[sslt@sslt Downloads]$ ./matlabconnector_1.3.0.2_glnxa64_installer.bin
/tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller)
/tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller)
/tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller)
/tmp/mathworks_20642/./bin/glnxa64/matlabconnectorinstaller: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /tmp/mathworks_20642/bin/glnxa64/libmwmcicore.so)
This also occurs when trying to use the MATLAB Engine API for Python.
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by path/matlab/R2019a/extern/engines/python/dist/matlab/engine/glnxa64/matlabengineforpython3_6.so)
How can I resolve this issue?
 

Best Answer

The "libstdc++" library shipped with CentOS in the older version does not contain the required GLIBCXX version. A workaround is to use MATLAB's libraries by setting the environment variable:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<matlabroot>/sys/os/glnxa64
setenv LD_LIBRARY_PATH {LD_LIBRARY_PATH}:<matlabroot>/sys/os/glnxa64
Another possible workaround is to upgrade the CentOS version to include the newer libraries.
Related Question