title: How can I get MatLab to find the Visual C++ Compiler?
body: <p><em>Preamble: I found a solution in the midst of writing this, and this problem was a PITA and had a convoluted solution. Thus, I feel compelled leave this here to help any poor soul who has this problem.</em></p>
  
  <hr>
  
  <p>I'm new to MatLab, and I don't usually use Visual C++ either, so forgive me if this should be painfully obvious.</p>
  
  <p>Short version: I have Visual C++ 2013 installed on my computer, but mex can't find it when I run <code>mex -setup c++</code>. I get the following:</p>
  
  <blockquote>
    <p><code>&gt;&gt;mex -setup cxx</code></p>
    
    <p>Error using mex</p>
    
    <p>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, see 
    <a href="http://www.mathworks.com/support/compilers/R2015b/win64.html" rel="nofollow noreferrer">http://www.mathworks.com/support/compilers/R2015b/win64.html</a>.</p>
  </blockquote>
  
  <hr>
  
  <p>Here's the full situation.</p>
  
  <ul>
  <li>OS: Windows 10 Home</li>
  <li>Compiler: Visual Studio 2013 (v120, up-to-date)
  
  <ul>
  <li>I confirmed that I can compile and run a program using this toolset.</li>
  </ul></li>
  <li>MatLab version: 2015b</li>
  </ul>
  
  <p>I was originally running Visual Studio 2015, and mex found the compiler just fine. However, I soon found out that Simulink is not compatible with VS 2015, so I had to roll back to VS 2013, and this is when my problem started.</p>
  
  <p>I've tried, among many others, the following sites to find a solution:</p>
  
  <ul>
  <li><a href="http://www.mathworks.com/help/matlab/ref/mex.html" rel="nofollow noreferrer">The MatLab mex documentation</a> - No help, only shows basic <code>mex</code> usage.</li>
  <li><a href="http://www.mathworks.com/support/compilers/R2015b/index.html" rel="nofollow noreferrer">The MatLab supported compiler list</a> - Confirmed that VC++ 2013 is compatable.</li>
  </ul>
  
  <p>Then I went down a rabbit hole.</p>
  
  <ol>
  <li><p><a href="http://www.mathworks.com/matlabcentral/answers/58684-mex-compiler-not-found-problem" rel="nofollow noreferrer">A very protracted mathworks.com answer that suggested other links</a>. This led me to...</p></li>
  <li><p><a href="http://www.mathworks.com/matlabcentral/answers/5510-unable-to-locate-compiler-mex-error-when-using-visual-c-2010-express-sp1-on-64-bit-windows" rel="nofollow noreferrer">Another mathworks.com answer</a> which sounds like my problem, and suggests patching my setup. Turns out that I don't have SDK 7.1 installed. So, I went to install, and got this error:</p>
  
  <blockquote>
    <p>Some components could not be installed. Some Windows SDK components require the RTM .NET Framework 4...</p>
  </blockquote></li>
  <li><p><a href="https://stackoverflow.com/questions/31455926/windows-sdk-setup-failure">This Stack Overflow question</a> asks about this issue, and I hit the exact same issue <a href="https://stackoverflow.com/users/5121581/danilo-gad%C3%AAlha">Danilo Gadêlha</a> had in regards to the .NET Framework already being installed.</p>
  
  <p>I tried the <a href="https://stackoverflow.com/a/32897993/1519716">top answer</a>, and after removing every single reference to .NET framework of <em>any</em> version I could find, including those under "Windows Features", I still couldn't install.</p>
  
  <p>I tried the <a href="https://stackoverflow.com/a/33260090/1519716">next option</a>, and even in safe mode, RegEdit wouldn't let me change the values suggested by the next answer, so that was a bust.</p>
  
  <p>Lastly, I tried <a href="https://stackoverflow.com/a/32145375/1519716">MandM's solution</a>, which <em>finally</em> solved my chain of problems.</p></li>
  </ol>