Visual Studio 2012 Compiler Update in Matlab - matlab

The Visual Studio 2012 Compiler November 2012 CTP (VS2012+) gives access to new C++11 features. I would like to build mex files from Matlab 2013a using VS2012+; Matlab 2013a supports the ordinary VS2012. Is it possible to make Matlab 2013a build with VS2012+?
Visual Studio 2012 Compiler November 2012 CTP:
http://www.microsoft.com/en-us/download/details.aspx?id=35515
Additional information:
In Visual Studio 2012, the compiler update is activated by going into project settings, and then choosing the platform toolset as "Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)". The default platform toolset is "Visual Studio 2012 (v110)". I would have expected to see this reflected in the compiler or linker switches, but I am unable to spot any differences. To key issue is then how to inform Visual Studio 2012 to do the same from the command line.

The Visual Studio 2012 Compiler Nov 2012 CTP is a separate executable, which is located at
C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP
The bin-subdirectory contains the cl.exe, which is the new compiler. A file with the same name exists at the Visual Studio 2012 installation directory. To make Matlab refer to the updated compiler, open (in a plain-text editor) the file
C:\Program Files\MATLAB\R2013a\bin\win64\mexopts\msvc110opts.bat
and add the following just before the compiler parameters:
rem Override the compiler selection.
set COMPILERUPDATEDIR=C:\Program Files (x86)\Microsoft Visual C++ Compiler Nov 2012 CTP
set PATH=%COMPILERUPDATEDIR%\bin\amd64;%COMPILERUPDATEDIR%\bin;%PATH%
This works since the cl.exe is searched from left to right in the PATH variable.
Local vs global options files
Note that the options-files in the mexopts directory are not directly used by Matlab; instead, they are taken local copies, and these are then used as the actual options files. When running
mex -setup
Matlab takes a local copy of the global options file, and places it in a directory which can be obtained by running mex with the -v option. This is the default options file. Therefore, if you are using the default options file, then you need to run mex -setup to see the changes.
Alternatively, you may want to take a local copy of the global options file yourself, and then specify the options file by the -f option in mex. This way you don't need to modify the official options files.

Related

No supported Visual C/C++ compiler found. Check your installation of Visual C/C++

I am using Matlab R2013a. The problem appears when I try to use Simulink Coder to generate Visual C++ code.
I've got this error even though I have Visual Studio 2013 installed on my computer already. When I look at list of programs that are installed on my computer I see Visual C++ 2008, 2010 and 2012. When I type the command mex -setup Matlab just can see a compiler LCC. But I need a Visual C++ compiler (which , technically, I already have) seen by Matlab.
How can I do that? Isn't mex -setup the right code?
You need MATLAB R2014a since support for Visual C++ 2013 was not added until MATLAB R2014a.
As a workaround, you can use this or this FileExchange submission to add support for building MEX files using Visual C++ 2013 with earlier MATLAB version.

How to prompt Matlab to use VS10 64 bit compiler

I am trying to compile and run a 64bit application in MATLAB using the Visual Studio 2010 Professional compiler. I know both the program and the compiler work properly because when I start matlab from the Visual Studio x64 command prompt I am able to run the program without an issue.
I have run mex -setup and selected the 2010 compiler as follows:
mex -setup Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[2] Microsoft Visual C++ 2008 Express in C:\Program Files (x86)\Microsoft Visual Studio 9.0
[0] None
Compiler: 1
Please verify your choices:
Compiler: Microsoft Visual C++ 2010 Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
************************************************************************* Warning: MEX-files generated using Microsoft Visual C++ 2010 require that Microsoft Visual Studio 2010 run-time libraries be available on the computer they are run on. If you plan to redistribute your MEX-files to other MATLAB users, be sure that they have the run-time libraries. *************************************************************************
Trying to update options file: C:\Users\OEM\AppData\Roaming\MathWorks\MATLAB\R2010a\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2010a\bin\win64\mexopts\msvc100opts.bat
Done . . .
Unfortunately this doesn't seem to allow me to run the 64bit application. I get an error regarding cl preprocessor commands, essential pointing to the fact I'm not using a 64 bit compiler. Does anyone know how I can configure this so that I will not need to run Matlab from the Visual Studio 2010 command line? I would appreciate any help on this.
Thanks so much in advance!
Don

Matlab deployement tool, Microsoft compiler

I'd like to know which specific file is my Microsoft compiler. I need it to compile some Matlab code. By running mex -setup mex is able to locate the compiler in the following directory : d:\Program Files (x86)\Microsoft Visual Studio 10.0 However when I browse there, there is no file that would possibly be the actual compiler.
I'd like to build my application, but it won't work, looks like Matlab indeed found the compiler, but I get an error (code = 53) An error occurred while shelling out to mbuild
So my guess then was that I had to go in the Deployement tool Settings and add some options like the compiler directory (even if I already set it with mex), but I can't find it in d:\Program Files (x86)\Microsoft Visual Studio 10.0 I don't even know what's the compiler's name.
I really need help on this one. Thanks!
For mex -setup to work correctly you don't need to know what the actual compiler is called. When I run mex -setup I get a list like this:
Select a compiler:
[1] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) in C:\Program Files (x86)\Intel\ComposerXE-2011
[2] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) in C:\Program Files (x86)\Intel\ComposerXE-2011
[3] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
and if I select [3] the informative output includes the lines
Trying to update options file: D:\Users\my.name\AppData\Roaming\MathWorks\MATLAB\R2012a\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2012a\bin\win64\mexopts\msvc100opts.bat
If you inspect either of those files you will find the name of the compiler (it's called cl.exe and there are a few different versions in directories below the one that Matlab suggests it is looking in) assigned to be the value of a script variable called COMPILER. You'll also find all the settings that mex uses when it compiles code into a mex-file. You may be able to diagnose the rest of your problem(s) from this information.
If you can't solve your problem(s) with this 'help', edit it and explain precisely the error messages and

No C compiler on matlab using mex, any simple compilers/solutions?

I've been crazy on these things all day...
I installed the Matlab2010a on remote desktop (64bits windows server 2008)
then I need to use the "mex" command to recompile the code (which is already compiled at my laptop(64-bits), but it doesn't work when I copy the .mexw64 to the remote one)
But on the remote desktop, there is no Visual Studio/VC6.0. And you know it's tooooo hard and not workable to install something like that on the remote desktop...
So, are there any other solutions for me to compile the .cpp on matlab?
Thank you so much, because I've been drived crazy...Jesus...
Try the following to see what compiler is available
mex
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2012a\sys\lcc
[2] Microsoft Visual C++ 2010 in C:\Program Files (x86)\Microsoft Visual Studio 10.0
The output shows that my MATLAB may use one of these two compilers to create mex files.
If I want to set up my another compiler, I have to use the following command
mex -setup

Matlab deploy tool- Windows stand alone application

I am trying to create a Windows stand alone application in Matlab using the Deploytool to produce a .exe file for my project. (as mentioned here: http://www.mathworks.co.uk/products/demos/compiler/deploytool/index.html).
The problem is when in the Deploytool I add my files and press the Build button it asks me to use mbuild -setup to setup my compiler. When I do so the only options I get are :
Would you like mbuild to locate installed compilers [y]/n? n
Select a compiler:
[1] Microsoft Visual C++ 2005 SP1
[2] Microsoft Visual C++ 2008 Express
[3] Microsoft Visual C++ 2008 SP1
[0] None
and when I choose any I get these:
*The default location for Microsoft Visual C++ 2008 Express compilers is C:\Program Files (x86)\Microsoft Visual Studio 9.0,
but that directory does not exist on this machine.
Please enter the location of your compiler:*
I also get the following error when I build:
*Could not find the compiler "cl" on the DOS path.
Use mbuild -setup to configure your environment properly.
C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Unable to locate compiler.
Error: An error occurred while shelling out to mbuild (error code = 2).
Unable to build executable.*
Can you please help me solve this problem.
Thanks in advance.
You need to allow mbuild to detect installed compilers. The Matlab compiler includes a default C compiler. On my Windows XP system, I get:
>> mbuild -setup
Welcome to mbuild -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2011a/win32.html
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011a\sys\lcc
[2] Microsoft Visual C++ 2010 in C:\Program Files\Microsoft Visual Studio 10.0
[3] Microsoft Visual C++ 2005 SP1 in C:\Program Files\Microsoft Visual Studio 8
[0] None
Compiler:
I have two versions of Visual Studio installed, but you can see the default compiler is in the MATLAB installation directory.
Ensure you answer 'y' when the script asks to locate installed compilers
You need to have a compiler installed on your computer. You can download Visual Studio Express from here: Visual Studio Express Download.
I installed Microsoft Visual Studio Ultimate on my computer. When asked for the location of the compiler in mbuild setup, I redirected it to C:\Program Files (x86)\Microsoft Visual Studio 10.0. This worked for me.
Go to following address {C:\Program Files\MATLAB\R2008a\toolbox\compiler\deploy\win32 }
and install this following setup - "MCRInstaller.exe" (This setup file is use for set run time compiler) after install you can use "deployment tool" your respective file like *.Project.
Enjoy...