For information about changing the gcc/g++ compiler to a supported version on Linux® platforms, see Change Default gcc Compiler on Linux System.
MATLAB® maintains separate default compiler options for C, C++, and Fortran
language files. If you have multiple MATLAB-supported compilers for a language installed on your Windows® system, then MATLAB selects one as the default compiler. To change the default, use the
command. MATLAB displays a message with links to select a different default
compiler.mex
-setup
lang
If you call
without the
mex
-setuplang
argument, then MATLAB displays information about the default C compiler. MATLAB also displays links to the other supported languages. To change the
default for another language, select a link.
If you call
from an operating
system prompt, MATLAB displays the same information. However, the messages do not contain
links. Instead, MATLAB displays the appropriate mex
-setupmex
command syntax for
changing the default compiler. Copy the command and paste it into the operating
system prompt.
The compiler you choose remains the default for that language until you call
to select a different
default.mex
-setup
To change the default C compiler, at the MATLAB command prompt, type:
mex -setup
defaults to information
about the C compiler. Alternatively, type:mex
-setup
mex -setup c
To change the default C++ compiler, type:
mex -setup cpp
For an example, see Choose a C++ Compiler.
To change the default Fortran compiler, type:
mex -setup Fortran
If you have multiple versions of Xcode installed on your system, MATLAB uses the compiler defined by the Xcode.app
application. You can use the compiler from an
Xcode.X.app
, where Xcode.X.app
is the name you used to save a previously installed Xcode version.
Before starting MATLAB, from the Terminal type:
xcode-select -switch /Applications/Xcode.X.app/Contents/Developer
To see which Xcode MATLAB is using, at the Terminal type:
xcode-select -p
mex -f optionsfile
SyntaxThe mex
command -f
option to specify a
build configuration file will be removed in a future release. Instead, use the
workflows described in this topic for specifying a compiler.