MATLAB: Setup MEX compiler for R2014a for Linux

mex compiler

Ubuntu 14.04 comes with GCC 4.8. Matlab 2014a only supports up to GCC 4.7. When I use 2013a I can set the mexopts.sh script to use GCC-4.7 by doing the following
1) In matlab, type mex -setup and press 1 to copy mexopts.sh to ~/.matlab/R2013b/mexopts.sh
2) From the terminal, edit the file ~/.matlab/R2013b/mexopts.sh so that CC=’gcc’ change to –> CC=’gcc-4.7′ CCX=’g++’ change to –> CCX=’g++-4.7′
In 2014a the mexopts.sh file does not exist anymore. When I type mex -setup I get the following error:
>> mex -setup C++
Error using mex
No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2014a/glnxa64.
I know GCC 4.7 is installed because it works for R2013b but how do I set compiler in 2014a?

Best Answer

Hi,
Beginning version R2014a, MATLAB automatically configures the mex pseudo compiler to use a supported compiler (such as gcc 4.7x ) on your machine. This leaves the use of the command “mex –setup” redundant unless you would like to use a supported compiler that is different from the default selection, or force MATLAB to use an unsupported compiler.
Did you try mexing a simple mex file like “timestwo.c” to check if the “mex file_name.x” command works on R2014a?
>> copyfile(fullfile(matlabroot,'extern','examples','refbook',...
'timestwo.c'), '.', 'f');
>> mex timestwo.c
Make sure you have write permission in your current working directory