Change Default gcc Compiler on Linux System
MATLAB® supports only one compiler for each language on Linux® platforms. If you have multiple compilers installed, the default compiler might not be a compiler that MATLAB supports. To determine the default gcc compiler for your system, in MATLAB, type:
To change the default compiler, choose one of these options.
Change the system
$PATHvariable. When you change the path, this compiler becomes the default for all applications on your system.
To change the
$PATHvariable, add the folder containing the compiler that MATLAB supports to the beginning of the path. Refer to your operating system documentation for the correct command to use.
Select a compiler that MATLAB supports when running the
mexcommand. To change the compiler, use the
varnamevariable set to
GCC, in uppercase letters.
For example, if the currently supported gcc compiler is version 6.3 and it is installed in the
/usr/bin/gcc-6.3folder on your system, to build
copyfile(fullfile(matlabroot,'extern','examples','refbook','timestwo.c'),'.','f') mex -v GCC='/usr/bin/gcc-6.3' timestwo.c
mex -setup command does not change the default compiler