Main Content

Choose a C++ Compiler

MATLAB® chooses a default compiler for building MEX files, a MATLAB interface to a C++ library, and standalone MATLAB engine and MAT-file applications. The default compiler for C++ applications might be different from the default compiler for C applications. To see the default C++ compiler, type one of these commands:

mex -setup cpp
mex -setup CPP
mex -setup c++

MATLAB also displays links to other C++ compilers on your system, if any. To change the default, select one of these links.

When you type this command, MATLAB shows you information for the default C compiler only.

mex -setup

Select Microsoft Visual Studio Compiler

This example shows how to determine and change the default compiler for building C++ applications when you have multiple versions of Microsoft® Visual Studio® on your system.

To display information for the C++ compilers installed on your system, type:

mex -setup cpp

To change the default, click one of the links. MATLAB displays information about this compiler, which remains the default until you call mex -setup cpp to select a different default.

Select MinGW-w64 Compiler

If you only have the MinGW® compiler installed on your system, MATLAB automatically chooses MinGW for both C and C++ applications. If you have multiple C or C++ compilers, type this command to choose a C compiler.

mex -setup

Type this command to choose a C++ compiler.

mex -setup cpp

If you only type mex -setup and choose MinGW, when you compile a C++ file, mex might choose a different compiler.

See Also


Related Topics