Why is MATLAB unable to find the Microsoft Visual C++ 2015 compiler after installing Microsoft Visual Studio 2015?

I installed Microsoft Visual Studio 2015 Professional, however "mex -setup" still does not successfully find the Microsoft Visual C++ 2015 compiler. This can be seen from the following output when running the command "mex -v -setup":
>> mex -setup -v
... Looking for compiler 'Microsoft Visual C++ 2015 Professional (C)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 14.0 ...No.
... Looking for registry setting 'HKCU\SOFTWARE\Microsoft\VisualStudio\SxS\VS7' 14.0 ...No.
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7' 14.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 14.0\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe' ...No.
Did not find installed compiler 'Microsoft Visual C++ 2015 Professional (C)'.
Error using mex
No supported compiler or SDK was found. You can install the freely available MinGW-w64 C/C++ compiler;
see Install MinGW-w64 Compiler. For more options, visit
http://www.mathworks.com/support/compilers/R2016a/win64.html.
How can I resolve this?

 Accepted Answer

This is likely caused by having installed Microsoft Visual Studio 2015 using the "Typical" setup option, which will not install the Visual C/C++ compiler by default. As a result, the actual C/C++ compiler (cl.exe) is missing from the installation and causes the "mex" command to fail. This is also highlighted in Microsoft's documentation: 
To resolve this issue, run the Visual Studio 2015 installer again and choose to perform a "Custom" setup. Then during installation, make sure to enable "Visual C++" under "Programming Languages".
If the detection still fails, verify that the Windows registry entries are pointing to the correct Visual Studio 2015 installation folder. In the example above, the "14.0" value under the registry key HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7 is set to:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\
If the returned location is not as expected, please contact your IT helpdesk to correct the registry entry.

More Answers (0)

Categories

Products

Release

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!