Matlab does not see C++ compiler - c++

I've recently installed Matlab R2016a.
When I try to execute
mex -setup
I've got the following message:
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
I did check the list and it turned out that I do have all tools in my system that are compatible with this Matlab version. I also installed Windows SDK for Windows 10.
Doest anyone know what might be the problem here?

After a while, I realised that Microsoft Visual Studio does not install C++ compiler through a express setup, which makes a lot of sense... I guess.

Related

How can I get MatLab to find the Visual C++ Compiler?

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.
I'm new to MatLab, and I don't usually use Visual C++ either, so forgive me if this should be painfully obvious.
Short version: I have Visual C++ 2013 installed on my computer, but mex can't find it when I run mex -setup c++. I get the following:
>>mex -setup cxx
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, see
http://www.mathworks.com/support/compilers/R2015b/win64.html.
Here's the full situation.
OS: Windows 10 Home
Compiler: Visual Studio 2013 (v120, up-to-date)
I confirmed that I can compile and run a program using this toolset.
MatLab version: 2015b
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.
I've tried, among many others, the following sites to find a solution:
The MatLab mex documentation - No help, only shows basic mex usage.
The MatLab supported compiler list - Confirmed that VC++ 2013 is compatable.
Then I went down a rabbit hole.
A very protracted mathworks.com answer that suggested other links. This led me to...
Another mathworks.com answer 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:
Some components could not be installed. Some Windows SDK components require the RTM .NET Framework 4...
This Stack Overflow question asks about this issue, and I hit the exact same issue Danilo Gadêlha had in regards to the .NET Framework already being installed.
I tried the top answer, and after removing every single reference to .NET framework of any version I could find, including those under "Windows Features", I still couldn't install.
I tried the next option, and even in safe mode, RegEdit wouldn't let me change the values suggested by the next answer, so that was a bust.
Lastly, I tried MandM's solution, which finally solved my chain of problems.
I think this was the root of my problem: when I uninstalled Visual Studio 2015 and installed Visual Studio 2013, an installation or registry setting was left in an incorrect state, and mex was unable to find Visual Studio 2013 as a result.
The solution that worked for me:
Leave Visual Studio 2013 installed.
As MandM answered:
Uninstall the following:
"Microsoft Visual C++ 2010 x64 Redistributable"
"Microsoft Visual C++ 2010 x86 Redistributable"
Before installing the Windows 7.1 SDK, and the install package reinstalls those two during installation.
As Robert Važan points out in the comments:
If error message persists despite this workaround, just click OK and proceed with installation. The installation will succeed this time..
I did get this error, but the install worked fine.
Install the SDK 7.1 Patch, which fixes the issue highlighted on this mathworks.com answer.

Install Visual C++ Compiler on Windows without installing whole Visual Studio

NOTE This question can be duplicate of this or this question.
But please don't close it as duplicate without reading entire question.
I'm trying to install npm module browsersync on Windows, and by reading its documentation, I found that module itself uses node-gyp which requires C++ compiler on Windows to build native extension. And that leads to installation of Visual Studio (community edition will do). After going through above linked questions (which I noted as duplicates of my current question), I found that Windows SDK used to ship with C++ compiler but now Visual Studio is required to have C++ compiler.
So my concern is, do I really need to download and install that hefty 6 GB VS Community edition just to get that C++ compiler to build browsersync on Windows? or is there any way to do that via GCC for Windows?
P.S. Earlier I faced similar situation for installing node-oracledb.
Thanks.
#Niall covered where you can get the actual C++ compiler, but if you're looking for further information on the problem there's a walkthrough on how to get node-gyp up and running on Windows on their github issues page with the standalone compiler.

How can I compile the vlfeat and mexopencv libraries in MATLAB using the Visual c++ compiler?

I am working on a computer vision project, and I need to use the vlfeat and mexopencv libraries,
I am working with MATLAB R2008a and I cannot change the MATLAB compiler to compile and setup the libraries.
I have installed Microsoft Visual C++ Express, but I don't know how to compile the libraries using the Visual C++ compiler in MATLAB.
The reason why you can't find the compiler is because you are using MATLAB R2008a. The C++ compiler you have downloaded is probably too new for MATLAB to use. My guess is that you are using Express 2013. See the following link on what compilers R2008a can support for MEX here:
http://www.mathworks.com/support/compilers/release2008a/
Specifically, for the Express edition of the Visual C++ compiler, it can only support up to Version 8.0. You are most likely using an Express edition that is newer than 8.0. As such, the only way for you to use the Visual C++ compiler with R2008a is if you download the 8.0 Express edition and install it.
You can find that compiler here: http://go.microsoft.com/fwlink/?LinkId=51410&clcid=0x409
Once you install the Visual C++ compiler, you also need to install the SDK. You can find that here:
http://www.microsoft.com/en-ca/download/details.aspx?id=6510
After you do this, you need to define the MSSdk environment variable. To do this,
go to Control Panel -> System then Advanced and Environment Variables. After, create a new variable with the name MSSdk and the value being the path of where you installed the SDK. For example: C:\Program Files\Microsoft Platform SDK for Windows Server 2003.
Good luck!

How set C/C++ compiler for matlab?

i've read several topics on this issue... but i'm not still able to figure out.
I've matlab 2013 and "MS Visual C++ 2012 Redistributable" both x86/x64 installed in Windows 8.
When i run "mex -setup" in matlab the following message appear:
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
No supported SDK or compiler was found on this computer.
For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html
but the suggested file is for installing .NET 4 for windows 7, and i've windows 8. However, although i install this framework the mex -setup command still doesn't works.
It seems to still be an issue with no straightforward solution. It took me a lot of searching, reading and trial and error to get a compiler to be recognized by mex.
In a nutshell, matlab 2013 doesn't support windows 8 SDK, but windows 7 SDK does not (easily) install on windows 8.
What worked for me:
The win7 SDK doesn't install on windows 8 because more recent versions of the Visual C++ 2010 Redistributable are already installed by default on Windows 8. You have to manually (from the control panel/programs/uninstal ...) uninstall all flavors of VC++2010 redistributable (x86 and x64).
See this Microsoft article for details on how to do that.
After that I could install the SDK for win7 and got the compiler to be recognized by mex.
Note:
I run on win8 32 bits, so what worked for me may not be perfect for everybody. During my searches on the subject i also noticed that many people often stumbled on 2 other setbacks:
During the setup of win 7 SDK, .NET 4 doesn't install. => This is because .net4.5 is already shipped in windows 8. Again, uninstall .net4.5, then reinstall win7 SDK. (you can even reinstall .net4.5 if necessary after everything is done).
Once everything is installed and mex happily found the compiler, error are raised during compilation tentative about a missing ammintrin.h. You may have to install MS Visual Studio C++ 2010 express then upgrade it to SP1. In this case follow the nicely detailed instructions in this Matlab central article.
This last article linked seem to offer a complete solution, i didn't refer to it first in my answer because in some case (my case for example), only part of the setup described was necessary, so there was no point uninstalling/reinstalling a bunch of stuff. But be prepared that you may have to go though all of it ...

How do I install the minimal facilities of Visual Studio 2008 sufficient for building C++ applications using Visual Studio 2010's multitargeting?

Dev10 has facilities for using the C++ compiler shipped in Orcas. However, I really don't need to install the full IDE -- I merely need to use Orcas' compiler because I need to support Windows 2000.
What's the simplest way of installing just the bits required to build using Orcas' toolset in Dev10?
Given your condition, I'd say just install VS2008 and use it. While it's not what you want it's the fastest path to working.
What about setting up Visual studio 2008 to work with Orcas compiler ?
I'm sorry I don't know about this very compiler, but I know it's possible to use VS2008 with a different compiler, because I tried it.
You can find plenty of doc on running VS2008 with, for example, the Windows SDK compiler or VS2010 compiler. For example that links explains that quite well : http://www.codeproject.com/Tips/105011/Using-Visual-Studio-2008-IDE-with-Visual-Cplusplus.aspx
HTH