Matlab R2013b C++ MEX on Ubuntu 14.04

Better to upgrade Matlab to a current version instead of 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 Matlab ≥ R2014a 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.


This example is for Matlab ≤ R2013b

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: