Matlab R2013b C++ MEX on Ubuntu 14.04

Ubuntu 14.04 comes with GCC 4.8, but Matlab R2013b wants GCC 4.8.
The error you will get includes.
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. You should 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. Yikes!

http://www.mathworks.com/matlabcentral/answers/67521-32bit-and-64bit-compilations#comment_216789

http://www.mathworks.com/help/matlab/release-notes.html

This example is for R2013b and OLDER

Resolution:
sudo apt-get install gcc-4.7 g++-4.7

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

chmod 644 ~/.matlab/R2013b/mexopts.sh

nano ~/.matlab/R2013b/mexopts.sh
there will be one instance each of:
CC=’gcc’ change to –> CC=’gcc-4.7′
CCX=’g++’ change to –> CCX=’g++-4.7′
5) restart Matlab

4 thoughts on “Matlab R2013b C++ MEX on Ubuntu 14.04”

  1. this does not seem to work on matlab r2014a and ubuntu 14.04. I just tried it and there was no change regarding which gcc matlab is actually using. Any suggestions?

    1. Hello Kostas,

      You’re right — this seems to be an outstanding issue upon which I have found a number of internet comments, including those from the Mathworks Ken Atwell saying Mathworks isn’t interested in allowing specification of 32-bit compilers — hmm, maybe they forgot that people need to specify specific version of compilers too.

      I would file a bug or support request with the Mathworks.

    1. Hello wei qi,
      As far as I know, the process of using mex in Matlab R2014a has not significantly changed from previous versions. What has changed is the
      mex -setup
      for Matlab R2014a, the old ways of specifying specific compiler versions via mexsetup.sh seem no longer available.

      I would just try to run your mex commands as usual and file a bug report with the Mathworks if something happens that seems to be due to needed an older GCC.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>