Downgrading gcc/g++ for use with mex

4 views (last 30 days)
KV
KV on 16 Jul 2017
Edited: Amit Doshi on 18 Jul 2017
I'm running Matlab 2017a on an Ubuntu 16.04.2 LTS (xenial). The default gcc/g++ versions are 5.4.0 and Matlab only supports version 4.9.x.
Are there good suggestions on how to "downgrade" the g++/gcc versions so that I can have mex working OK?
Thanks,

Answers (1)

Amit Doshi
Amit Doshi on 18 Jul 2017
Edited: Amit Doshi on 18 Jul 2017
Hello Karthik,
To change the compiler in the mex command, set the varname variable. varname for the gcc compiler is GCC, in uppercase letters. For example, if the currently supported gcc compiler is version 4.7, and it is installed in the /usr/bin/gcc-4.7 folder on your system, to build timestwo.c, type:
copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.c'),'.','f')
mex -v GCC='/usr/bin/gcc-4.7' timestwo.c
Setting the compiler using the mex command does not change the system default compiler.
Also, refer the below link to downgrade GCC in Ubuntu:

Categories

Find more on Write C Functions Callable from MATLAB (MEX Files) 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!