Main Content

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 themex-setuplangcommand. MATLAB displays a message with links to select a different default compiler.

If you callmex-setupwithout thelangargument, 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 callmex-setupfrom an operating system prompt, MATLAB displays the same information. However, the messages do not contain links. Instead, MATLAB displays the appropriatemex命令语法改变默认的编译器。Copy the command and paste it into the operating system prompt.

The compiler you choose remains the default for that language until you callmex-setupto select a different default.

C Compilers

To change the default C compiler, at the MATLAB command prompt, type:

mex-setup

mex-setupdefaults 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.

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.appapplication. You can use the compiler from anXcode.X.app, whereXcode.X.appis 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 optionsfileSyntax

Themexcommand-foption 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.

See Also

Related Topics

External Websites