Matlab MinGW / Intel compiler setup

Matlab requires C / C++ / Fortran compilers for numerous operations such as mex, loadlibrary and more. Windows Matlab supported compilers locations are communicated to Matlab via environment variables. Verify Matlab MEX parameters:


It’s possible to switch back and forth if multiple compliers are setup with MEX. The commands to do so will be at the bottom of the output when using the “mex setup” commands below.

Tell Matlab the MinGW compiler path via Windows environment variable MW_MINGW64_LOC.

Find the MinGW compiler location from PowerShell:

(Get-Item((Get-Command gcc.exe).Path)).Directory.FullName

Put that path in Matlab:

setenv('MW_MINGW64_LOC', '<path of gcc.exe>')

One-time setup MEX C / C++:

mex -setup -v C
mex -setup -v C++

Intel oneAPI compiler with Matlab:

mex -setup -v C
mex -setup -v C++
mex -setup -v Fortran

If Matlab can’t find oneAPI, ensure the oneAPI and Visual Studio versions are in the Matlab supported compiler table linked at the top of this article.