Matlab R2013b C++ MEX on Ubuntu 14.04

You should upgrade Matlab to a current version instead of fiddling with the procedure below

Ubuntu 14.04 comes with GCC 4.8, but Matlab R2013b wants GCC 4.8.

Warning: You are using gcc version ‘4.8.2’. The version of gcc is not supported.

Note that Matlab R2014a uses a new system for MEX configuration. Do not use this process for R2014a and newer For Matlab R2014a I don’t have a solution for specifying gcc-4.7 besides taking the output of mex -v and editing the commands to use gcc-4.7 manually.\#comment\_216789

This example is for R2013b and OLDER


sudo apt install gcc-4.7 g++-4.7

cp /usr/local/MATLAB/R2013b/bin/ ~/.matlab/R2013b/

chmod 644 ~/.matlab/R2013b/

nano ~/.matlab/R2013b/

change to one instance each of: