Setup MEX compiler for R2014a for Linux

28 views (last 30 days)
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 script to use GCC-4.7 by doing the following
1) In matlab, type mex -setup and press 1 to copy to ~/.matlab/R2013b/
2) From the terminal, edit the file ~/.matlab/R2013b/ so that CC=’gcc’ change to –> CC=’gcc-4.7′ CCX=’g++’ change to –> CCX=’g++-4.7′
In 2014a the 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
I know GCC 4.7 is installed because it works for R2013b but how do I set compiler in 2014a?
  1 Comment
Awais Ashfaq
Awais Ashfaq on 22 Feb 2016
Hi, I have a similar problem. Where should I copy the I can't find any folder MATLABversion? Cheers

Sign in to comment.

Accepted Answer

Mukul Rao
Mukul Rao on 14 Jul 2014
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
wided hechkel
wided hechkel on 11 Feb 2017
Should i delete the from MatlabRoot"/bin/ after changing and copying it to ~/.matlab/"MatlabVersion" ?

Sign in to comment.

More Answers (3)

JIAWEI WU on 26 Jan 2015
Thanks Sergey, I copied the file mexopts.h as you said, it works here. it cost me one night to fix it, until now, finally, it has been solved. you are so great!

Dave on 14 Apr 2017
Edited: Dave on 16 Apr 2017
My solution for R2017a on Ubuntu 16.04.
First install the version of GCC Matlab expects:
sudo apt-get install gcc-4.9
Then edit the configuration file to point to this:
cd ~/.matlab/R2017a
sudo chmod 777 mex_C_glnxa64.xml
gedit mex_C_glnxa64.xml
Within that xml file, replace:
Save file and Matlab should no longer produce wrong version warnings.
  1 Comment
Jay Stanley
Jay Stanley on 16 Mar 2018
This solution works on R2017b / Ubuntu 17.10

Sign in to comment.

wided hechkel
wided hechkel on 11 Feb 2017
Should i delete the from MatlabRoot"/bin/ after changing and copying it to ~/.matlab/"MatlabVersion" ?
  1 Comment
jie Chang
jie Chang on 12 Mar 2017
Hello,could you tell me where the direction ~/.matlab/“MatlabVersion”is? thank you.

Sign in to comment.


Find more on MATLAB Compiler in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!