Matlab R2013b C++ MEX on Ubuntu

It’s better to upgrade Matlab to a current version instead of the procedure below. This procedure is for Matlab ≤ R2014a. Matlab ≥ R2014a uses a new system for MEX configuration.

Matlab R2013b wants GCC 4.7, so with more modern Linux systems, errors may occur like:

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


This example is for Matlab ≤ R2013b. Do not use this process for Matlab ≥ R2014a.

apt install gcc-4.7 g++-4.7

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

chmod 644 ~/.matlab/R2013b/

in ~/.matlab/R2013b/ change to one instance each of: