Change Default Compiler
To Change Default onWindowsSystems
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
-setuplang
If you call
without themex
-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 appropriatemex
-setupmex
命令语法改变默认的编译器。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-setupc
C++ Compilers
To change the default C++ compiler, type:
mex-setupcpp
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, seeChoose a C++ Compiler.
Fortran Compilers
改变默认的Fortran编译器,类型:
mex-setupFortran
To Change Default onLinuxSystems
For information about changing the gcc/g++ compiler to a supported version on Linux®platforms, seeChange Default gcc Compiler on Linux System.
To Change Default onmacOSSystems
If you have multiple versions of Xcode installed on your system, MATLAB uses the compiler defined by theXcode.app
application. You can use the compiler from anXcode.X.app
, whereXcode.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 Usemex -f optionsfile
Syntax
Themex
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.