How can I get MatLab to search for a Visual C ++ compiler?

Preamble: I found a solution in the middle of writing this, and this problem was PITA and had a difficult solution. So I feel compelled to leave it here to help any poor soul who has this problem.


I'm new to MatLab and I usually don't use Visual C ++, so goodbye if this should be painfully obvious.

Short version: I have Visual C ++ 2013 installed on my computer, but mex cannot find it when I run mex -setup c++ . I get the following:

>>mex -setup cxx

Error using mex

No supported compiler or SDK found. You can install the freely available MinGW-w64 C / C ++ compiler; see Installing the MinGW-w64 Compiler. For more options, see http://www.mathworks.com/support/compilers/R2015b/win64.html .


Here is the full situation.

  • OS: Windows 10 Home
  • Compiler: Visual Studio 2013 (v120, current)
    • I have confirmed that I can compile and run the program using this toolkit.
  • MatLab Version: 2015b

I originally ran Visual Studio 2015, and mex found the compiler just fine. However, I soon learned that Simulink is not compatible with VS 2015, so I had to return to VS 2013, and that was when my problem started.

I tried, among many others, the following sites to find a solution:

Then I went down the rabbit hole.

  • A very protracted response by mathworks.com that suggested other links . It led me to ...

  • Another mathworks.com answer that sounds like my problem and suggests fixing my installation. It turns out I do not have SDK 7.1. So, I went to the installation and got this error:

    Some components cannot be installed. Some Windows SDK components require RTM.NET Framework 4 ...

  • This stack overflow question asks about this problem, and I got into the same Danilo Gadêlha problem regarding the already installed .NET Framework.

    I tried the best answer , and after removing every link to the .NET framework of any version that I could find, including in the "Windows Features" section, I still could not install it.

    I tried the following option , and even in safe mode, RegEdit did not allow me to change the values ​​suggested in the next answer, so it was a recession.

    Finally, I tried the MandM solution , which finally solved my chain of problems.

+5
source share
1 answer

I think this was the root of my problem: when I uninstalled Visual Studio 2015 and installed Visual Studio 2013, the installation or registry setting was left in the wrong state and mex could not find Visual Studio 2013 as a result.

Solution that worked for me:

  • Leave Visual Studio 2013 installed.
  • As MandM answered :

    Delete the following:

    • "Redistributable Microsoft Visual C ++ 2010 x64"
    • "Redistributable Microsoft Visual C ++ 2010 x86"

    Before installing the Windows 7.1 SDK, the installation package will reinstall the two during installation.

    As Robert Vazhan points out in the comments:

    If the error message persists despite this workaround, just click OK and proceed with the installation. In this case, the installation will be successful.

    I got this error, but the installation worked fine.

  • Install the 7.1 Patch SDK , which fixes the issue highlighted by this mathworks.com answer .
+2
source

Source: https://habr.com/ru/post/1243812/


All Articles