How to configure/install a compiler for Matlab?

To run a commercial version of MANATEE, you will need to setup a compiler in matlab. Otherwise, you may encounter errors when running MANATEE like (the error message depend of your matlab version/configuration):

Error using loadlibrary (line 254)
A 'Selected' compiler was not found. You may need to run mex -setup

Error in C:\MANATEE\X_Y_Z\Protection\protection.p>protection (line 49)
Index exceeds matrix dimensions.
Error in loadlibrary>getLoadlibraryCompilerConfiguration (line 527)
Error in loadlibrary (line 263)
Error in protection (line 49)
Error in run_MANATEE (line 57)

You don’t need to setup a compiler to use the Trial version.

Check and select your compiler

To check if you have a Matlab compatible compiler installed you must use the command:

mex -setup

If you already have some compiler installed, the command will ask to detect them:

Matlab mex -setup: detect the compiler
Matlab mex -setup: detect the compiler

Type "y" then "enter" and matlab will display the list of available compatible compilers:

Matlab mex -setup: select the compiler
Matlab mex -setup: select the compiler

Finally select the compiler you want to use. In this example we want to use the SDK compiler so we type "1" then "enter".

Install a Compiler for Matlab

If you don’t have a compiler, there are several available ones. The choice of the compiler may depend of your computer and Matlab version. In this article we will detail the installation of some compilers that solved the issue for several client, it may not work for your specific case. Matlab provides a list of the compatible compiler according to the version. If you didn’t manage to install any of the compiler please contact Matlab support. Once the compiler installed, you will have to select it inside matlab with mex -setup as explained above.

Visual C++ compiler / Windows SDK

This compiler is included in the Windows SDK. You will find a dedicated article on mathworks. Basically, you need to download the installer on windows website and then follow the process. Note that the procedure may fail if you already have some Visual C++ Redistributable installed as explained in stackoverflow.


This compiler is complicated to install. Normally it should be accessible in the add-ons of Matlab and should be possible to install in few clicks. But the download link is broken and the installation process needs to be done "by hand". You will find all the useful information on Mathworks website:
- Mingw Add-on page
- How to install Mingw "by hand"

Update: The download issue has been corrected starting from Matlab version R2015b

Previous Next