Matlab is not able to load required libraries
Closed this issue ยท 9 comments
For some versions of Ubuntu and Matlab, the toolbox that require Matlab such as WBToolbox, WBIToolboxControllers and IDynTree complain about missing libraries. Here is the output for WBToolbox:
Invalid MEX-file '/home/DanielePucci/Software/codyco-superbuild/build/install/mex/WBToolbox.mexa64':
/home/DanielePucci/Software/matlab/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6:
version `GLIBCXX_3.4.21' not found (required by /home/DanielePucci/Software/codyco-superbuild/build/install/mex/WBToolbox.mexa64)
This issue has been temporarily solved adding to the .bashrc
alias matlab="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab"
The error comes out with Ubuntu xenial, Matlab version is 2016a and gcc version is 5.3.1 20160413
I solved the problem in a more permanent way my renaming the matlab's libstdc++.so.6
to a different name:
sudo mv /usr/local/MATLAB/R2016a/sys/os/glnxa64/libstdc++.so.6 /usr/local/MATLAB/R2016a/sys/os/glnxa64/libstdc++.so.6.back
In this way matlab always finds the system libstdc++.so.6
instead of its own version, regardless of how you call it.
This is extremely important to make sure that matlab
works correctly even when is not called by the terminal, for example when it is called by CTest
while running some automatic tests for some repositories with matlab tests, such as iDynTree
or mex-wholebodymodel
.
Every now and then these runtime issues pop up.
An additional alternative, which probably can be the more clean than the two previous, is to copy the file in matlabroot/bin/.matlab7rc.sh
into the user's home folder, e.g. on macOS
cp /Applications/MATLAB_R2016b.app/bin/.matlab7rc.sh ~/.matlab7rc.sh
and modifying it by looking for the corresponding architecture section (e.g. glnx* for linux, ...) and add the libraries to the LDPATH_PREFIX
variable.
For example in my case:
LDPATH_PREFIX='/usr/local/opt/gcc/lib/gcc/6/'
You can also check that this works, by executing the following line in the Matlab prompt (this is for mac, but it suffices to change DYLD_LIBRARY_PATH
into LD_LIBRARY_PATH
for linux).
getenv('DYLD_LIBRARY_PATH')
and check that the paths in LDPATH_PREFIX
are before the matlab paths, e.g.
>> getenv('DYLD_LIBRARY_PATH')
ans =
/usr/local/opt/gcc/lib/gcc/6/:/Applications/MATLAB_R2016b.app/sys/os/maci64:/Applications/MATLAB_R2016b.app/bin/maci64/../../Contents/MacOS: ...
This workaround is still required
Ubuntu Xenial
Matlab 2016b
GCC 5.4.0 20160609
cc @fjandrad
This information need to be moved to some FAQ or QA issue.
Moved the problem of properly documenting this at the superbuild level in robotology/robotology-superbuild#64 .
I tried to run the standup controller from whole-body-controllers on a new installation of MATLAB Version 9.4 (R2018a), Simulink Version 9.1 (R2018a). While trying to run the simulink model "unable to run the MATLABWindow application" warning message with other error messages are thrown and the model was terminated without running. @gabrielenava and I followed this issue and renamed all the libglib-*
files to libglib-*.old
. This solved the issue and the simulink model is running without errors now.
@Yeshasvitvs on which version of Ubuntu you had this problem?
@traversaro Ubuntu 18.04