MATLAB Community

MATLAB, community & more

Update From the World of MEX: Visual Studio 2010 Support 20

Posted by Michael Katz,

This week I’d like to welcome back guest blogger, Ken Atwell from the MATLAB Product Management team this week to talk about our support of Visual Studio 2010.

With the recent release of Microsoft Visual Studio 2010, we were almost immediately asked, “does it work with MATLAB”? Since Visual C++ 2010 was released after MATLAB R2010a, it could not be officially supported in the shipping release. With Visual C++ 2010 now “gold” and validated, we are making available a patch to 64-bit and 32-bit MATLAB R2010a (naturally, for Windows) that allows you to build MEX files with this new version of Visual C++. The patch supports both the Professional and Express versions of Visual C++, and will work with both the Professional and Student versions of MATLAB. This patch works only with R2010a; using the patch with any version of MATLAB other than R2010a is not supported.

And, while we’re talking about compilers for Windows, we often get asked, “Where can I get a free compiler for Windows (especially 64-bit Windows)?” Visual C++ Express is free and probably your best option. If you are using Visual C++ Express with 64-bit MATLAB, you will also need to install a matching version of the Windows SDK (also free) to get the 64-bit compiler you’ll need.

All of the above is captured in our Supported and Compatible Compilers page, which should be everyone’s first-stop shop for information concerning what compilers MATLAB supports.

What compiler do you use with MATLAB, if any? Chime in below!


Comments are closed.

20 CommentsOldest to Newest

Drazick replied on : 1 of 20

Taking advantage of this issue.
Could you integrate 64 bit C++ compiler into the next iteration of Matlab as you do for the 32 bit versions?

Because you don’t the integration between Photoshop CS5 and Matlab won’t work.

Ken Atwell (MathWorks) replied on : 2 of 20

Drazick, as you’ve noticed, MATLAB includes a basic compiler, lcc, on 32-bit Windows. Unfortunately, lcc is not available on 64-bit Windows, so you need to provide your own. Installing Visual C++ Express and the matching Windows SDK (both free) and should suit your needs. See for all options.

I am not familiar with the MATLAB integration that CS5 provides, so I cannot offer specific guidance. These threads from Adobe’s web site may be instructive and suggest that 64-bit can be made to work if both MATLAB and CS are 64-bit:

Dvijotham replied on : 3 of 20

Thanks for the patch, I’m able to use VS 2010 for my mexing needs now. However, I’m still not able to use it to generate mex files from the Embedded MATLAB code subset. Any advice on this?

Björn replied on : 4 of 20


I need to mex some files in 64-bit MATLAB 2010a on Windows 7. I have Microsoft Visual Studio 2010 Professional installed, and also the VS2010MEXSupport downloaded, unzipped and put into the MATLAB2010a directory. Still the mex -setup does not find Microsoft Visual C++ 2010.
What am I doing wrong?

thanks in advance

Ken Atwell (MathWorks) replied on : 5 of 20

As of last week, R2010b was released. It includes much richer support for Visual Studio 2010; no patch is needed. See

@Dvijotham, the patch enables MEX compilation only. For Embedded MATLAB, you will need to move to R2010b to use Visual Studio 2010.

@Björn, sounds like you’re doing the right things. Double-check that the patch was unzipped to the right place, and if problems persist, please contact technical support.

Jan Simon replied on : 8 of 20

Is the SP1 recommended for MSVC2010 Express together with MATLAB 2011a? While I can install the SP1 for MSVC2010, the installation of the SP1 for the WinSDK7.1 fails due to mysteriously missing prerequisites.

David replied on : 10 of 20

After installing Matlab 2010a x32 on windows 7 x64 all was well. After installing VS2010MEXSupport to enable compilation with VS2010pro, matlab failed to start with the error “Windows cannot find C:\Program Files (x86)\MATLAB\R2010a Student\bin\win64\vcredist_x64.exe.” Placing the required file in that directory didn’t seem to help.

Change all matlab 2010a shortcuts from
“C:\Program Files (x86)\MATLAB\R2010a Student\bin\matlab.exe”

“C:\Program Files (x86)\MATLAB\R2010a Student\bin\win32\MATLAB.exe”

use this executable, and all is well.

Thanks for the patch information.

dominique replied on : 12 of 20

I just see something horrible !!!! : this patch does not work with dlls !!!!! only Mex file !


Duc Pham replied on : 14 of 20

I am using Matlab 2010b. I also installed Microsoft Window SDK7.1. When I use command: mex -setup. Matlab could not find the new compiler. I found only lcc-win32 v2.4.1. Is there a way for Matlab to automatically find the new compiler? If not, what should I do so that Matlab can find the new compiler? Thanks.

Sridutt replied on : 16 of 20

Hi, I had a PC with R009b & MSVStudio2008. There were no compatibility issues. Now my new PC has R2009b and MSVC++ Express 2010. There are problems getting the same codes work with.
1. The MSVStud doesn’t show upin mex -setup.
2. LCC giving errors saying iostream not found etc.

What is the way to go around with R2009b is fixed?
Also is mex from one machine reusable in other? Like exe’s as I am not finding them to be so.

Sridutt replied on : 18 of 20

Thanks Aurélien,

I’ve 1 more Question. Are mex executables reusable with other PC’s (Same Matlab version)?

Aurélien replied on : 19 of 20

Yes the most important thing is mex-files can only be run under the same Operating System.
Your mex file is platform dependent , a windows mex-file (mexw32/mexw64 extension) will not work under Linux or Mac for example.

Andreas replied on : 20 of 20


I want to ask if there is a patch for using Matlab R2008a and MVS2010 too. My intend is to compile C-Code with mex from Matlab and to debug the application (sfunction integrated in simulink) by attaching to the matlab process from visual studio.

Thanx in advance