Change Default Compiler
To Change Default on Windows Systems
MATLAB® maintains separate default compiler options for C, C++, and Fortran
language files. If you have multiple compilers that MATLAB supports 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
C Compilers
To change the default C compiler, at the MATLAB command prompt, type:
mex -setup
defaults to information
about the C compiler. MATLAB also displays links to other C compilers on your system. To change
the default, select one of these links.mex
-setup
Alternatively, type:
mex -setup c
C++ Compilers
To change the default C++ compiler, type:
mex -setup cpp
MATLAB displays information about the default C++ compiler and provides links to other C++ compilers on your system. To change the default, select one of these links. For an example, see Choose a C++ Compiler.
Fortran Compilers
To change the default Fortran compiler, type:
mex -setup Fortran
To Change Default on Linux Systems
For information about changing the gcc/g++ compiler to a supported version on Linux® platforms, see Change Default gcc Compiler on Linux System.
To Change Default on macOS Systems
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
Do Not Use mex -f optionsfile
Syntax
The 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.