Using Visual Studio 2013's C compiler for MATLAB - c++

I added Visual Studio 2013 as the default C compiler for MATLAB using the mex -setup command. I added Visual Studio 2013 using a download I found on the internet with the following instructions.
The files
* msvc120engmatopts.bat
* msvc120opts.bat
* msvc120opts.stp
should be copied to C:\Program Files\MATLAB\R2013a\bin\win64\mexopts .
The files
* msvc120compp.bat
* msvc120compp.stp
should be copied to C:\Program Files\MATLAB\R2013a\bin\win64\mbuildopts .
My version of MATLAB is R2011b, so I replaced the path appropriately.
Here's me using it to run a C function to verify if the compiler has been linked.
Log File
I found out about this method from this answer.
However, when I use a MATLAB function within a Simulink Model, I get the following error message just like I did before I linked the VS2013 compiler to MATLAB.
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler.

Okay, so the only thing that works for my version of MATLAB "R2011b" is Microsoft SDK 7.1 since the other compilers are too old for Windows 7 64 bit. MinGW-64 bit is unsupported. Although it works on MATLAB it is not recognized by Stateflow.
So I just downloaded the .iso file from here.
If you face any difficulty while installing the SDK, then try this.

Related

MATLAB how to change default compiler?

I am working with MATLAB R2015b and trying to use MEX files. When I type the commad line "mex - setup", MATLAB returns me "MEX configured to use 'Microsoft Windows SDK 7.1(C)' for C language compilation". However, to change this default compiler to work with Microsoft Visual Studio Community.
How can I change the default compiler of MATLAB?
mex -setup lets you choose the compiler over the installed supported compilers you have.
Obviously the compiler needs to be installed , and needs to be one of the following : https://uk.mathworks.com/support/compilers/R2015b/index.html .
"Microsoft Visual Studio Community" does not appear to be on the list.

matlab mex cannot find vcomp.lib when openmp is used

I am trying to mex a c++ source file containing openmp usages. In the mex command, i have added COMPFLAGS="/openmp $COMPFLAGS" but it says cannot find vcomp.lib. My matlab mex have been setup to use the compiler of Windows SDK 7.1 located in C:\Program Files. I checked the lib files inside this SDK and didn't find vcomp.lib. Anyone knows how can I install openmp to Windows SDK 7.1? Thanks a lot!
Based on this thread, it seems openmp is not shipped with Windows SDK. It is only shipped with Visual Studion Professional or Ultimate.
This matlab central site proposed a method to enable the matlab mex to use the Visual Studio 2013 compiler instead of the Windows SDK compiler. OpenMP is shipped with Visual Studio 2013 Professional and I can now compile code with OpenMp Enabled!

MATLAB R2013b does not support Visual Studio 2013?

I have recently installed VS 2013. I have a .cpp project which I want to compile into mex with MATLAB 2013b. As soon as I enter:
mex -setup
in MATLAB and then I select "y" for "Would you like mex to locate installed compilers?", I receive the message that: "No supported SDK or compiler was found on this computer."
How can I get around this problem?
Visual Studio 2013 is not supported by MATLAB R2013b. See this link for more details: http://www.mathworks.com/support/compilers/R2013b/. The latest compiler and environment that R2013b can support for Windows is Visual Studio 2012. Your options are to either downgrade your version of Visual Studio to one that is compatible on that list I referred you to, or upgrade your version of MATLAB to at least R2014a or higher.

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!

Using nvcc with CUDA 6 and VS 2012 Express

I'm trying to get started with CUDA and a 64-bit compiler on Windows 7 SP 1. Ultimately, I wish to compile mex-files for use with Matlab (R2014a). I have an older computer which I successfully configured to do this using older versions of CUDA and VS C++ Express, but I can't seem to get it to work with the newer packages.
I've installed CUDA 6.0 and Visual Studio C++ 2012 Express, which web readings suggest should work together. I'm not sure whether I also need the Microsoft SDK, which used to be necessary in order to get the 64-bit compilers; it seems that these are included with VS these days.
I created a vcvars64.bat inside 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\x86_amd64'. I also made a copy of the entire directory renamed to 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64'. These steps used to be necessary for older versions -- not sure if they still are.
However, when I try to compile, I get the following error:
nvcc : warning : The 'compute_10' and 'sm_10' architectures are
deprecated, and may be removed in a future release. nvcc : fatal
error : nvcc cannot find a supported version of Microsoft Visual
Studio. Only the versions 2008, 2010, and 2012 are supported
Compilation errors found: terminating.
I'm compiling as follows:
nvcc --cuda myfile.cu --output-file myfile.cpp
Following this I would call mex within Matlab to build the mex file. But I can't get past this first step. Does anybody know how nvcc determines where to look for the compiler, and how I can get it to recognize a supported compiler? Note that 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\amd64\cl.exe' is on the system path.
Try to run vcvars64.bat and matlab both from the command line. This makes the correct VS environment variables known to Matlab and nvcc.