MATLAB system commands
I’m trying to run R from Matlab using the system
command. When I entered
command system('R'),
I get the following error:
/usr/lib64/R/bin/exec/R: /usr/local/MATLAB/R2014a/sys/os/glnxa64/libstdc++.so.6: version `CXXABI_1.3.8′ not found (required by /lib64/libicuuc.so.52)
/usr/lib64/R/bin/exec/R: /usr/local/MATLAB/R2014a/sys/os/glnxa64/libstdc++.so.6: version `CXXABI_1.3.8′ not found (required by /lib64/libicui18n.so.52)
R works fine when I use it outside of Matlab. I’m using Linux.
Solution
The answer can be found in How to tell mex to link with the libstdc++.so.6 in /usr/lib instead of the one in the MATLAB directory? Found
Essentially, Matlab uses its own version of libstdc++.so.6
when running commands from the system, so you must ensure that the system uses libstdc++.so.6 in the default location of your computer.
% Save library paths
MatlabPath = getenv('LD_LIBRARY_PATH');
% Make Matlab use system libraries
setenv('LD_LIBRARY_PATH',getenv('PATH'))
system( 'R' )
% Reassign old library paths
setenv('LD_LIBRARY_PATH',MatlabPath)