Downgrading gcc/g++ for use with mex

3 次查看(过去 30 天)
KV
KV 2017-7-16
编辑: Amit Doshi 2017-7-18
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,

回答(1 个)

Amit Doshi
Amit Doshi 2017-7-18
编辑:Amit Doshi 2017-7-18
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:

类别

Help CenterFile Exchange 中查找有关 Write C Functions Callable from MATLAB (MEX Files) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by