No BSD License  

4.4 | 8 ratings Rate this file 235 Downloads (last 30 days) File Size: 14.6 KB File ID: #22689 Version: 1.0

Microsoft 32/64-bit Visual C++ 2008 Express support files


Larry Baker (view profile)


MEX and MBUILD setup files for 32/64-bit Microsoft Visual C++ 2008 Express and Windows Platform SDK.

| Watch this File

File Information

These instructions and setup files can be used to download, install and configure Microsoft's free Visual C++ 2008 Express compiler with MatLab on either 32-bit or 64-bit Windows OS, using the latest Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. (We tried the solution in article 18508, but those files did not work for the latest Microsoft products.) We use MatLab R2007a on Windows XP Professional and Windows XP Professional x64 Edition. It should be straightforward to modify these files, if necessary, for use with the standard Microsoft Visual Studio C++ 2008 product and/or later versions of MatLab.

The files provided assume the installations are on the C: drive. To use another drive, edit the files and change C: to the correct drive letter.

After performing the steps in these instructions, setup the Microsoft Visual C++ 2008 Express compiler to create MatLab MEX files, for example, with "mex -setup" at the MatLab prompt.


Microsoft Visual Studio 2008 Mex And Mbuild Setup Files inspired this file.

MATLAB release MATLAB 7.4 (R2007a)
Other requirements Microsoft Windows Microsoft Windows x64 Edition MEX
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (23)
25 Jan 2015 chaodong yuan  
02 Mar 2013 WurmD

WurmD (view profile)

The link in your README to download MSVS2008 no longer works

I downloaded it from (but it's in Portuguese)

and Windows SDK for Windows Server 2008 and .NET Framework 3.5 from

Comment only
31 Jul 2012 Swasti Khuntia

Thanks a lot !!!!

27 Nov 2011 Jessie Ryan

did anyone successfully get Visual Studio 10 to work with Matlab R2009a?

Comment only
13 Jul 2011 Jac Billington


Thanks for this code, I'm trying to get this working with Windows XP, 32bit, Matlab R2009b. VS-2010.

Whilst I'm not getting any errors when I run mex -setup I don't get my c++ compiler in the list, just
Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB~1\R2009b\sys\lcc

If anyone could offer a solution I'd be grateful, going in circles on this.

thanks. J

Comment only
29 Jun 2011 Park

Park (view profile)


Comment only
19 May 2011 Herm4nn1

Snowread Wang's worked for Matlab 2007b and Visual Studio 2008 Standard edition. Million thanks!

18 Feb 2011 Larry Baker

Larry Baker (view profile)

I am pleased that so many have made good use of my submission. I would have been able to submit more recent versions of my code, except Mathworks changed the policy governing material posted to MATLAB Central File Exchange to require a BSD license. I work for the US Government. Works by US Government employees are not subject to copyright. While it is nice to receive acknowledgement, we cannot compel anyone to do that. There is no provision in the BSD license that exempts works produced by the US Government. Therefore, I have declined to attach a BSD license to this submission, and I have refrained from making any further submissions. Until Mathworks relaxes this requirement, I can no longer participate in this community sharing project. This is unfortunate.

Larry Baker
US Geological Survey

Comment only
19 Jan 2011 Ilham

Ilham (view profile)


Is there anyone here had connected X-Plane (Flight Simulator) with Simulink ?

Comment only
19 Oct 2010 Uni A

Uni A (view profile)


I followed all the instructions, and replaced the three files too. But now, when I type mex -setup, MATLAB doesn't even do what it was doing previously i.e showing me a list of compilers. Now what do I do? I have replaced the files, there is no turning back.

I am using MATLAB 7 with Windows Vista.
Please help!

Comment only
25 Jun 2010 Audrey

Audrey (view profile)

I got error when I try to call the mexfunction.

Matlab 2006b, VS 2008 professional. I don't have any error to compile the mexfunction and created xxx.mexw32

But when I try to call the mexfunction, got the error:

??? Invalid MEX-file xxxx.mexw32 : Invalid access to memory location.

Can you help. Since my VS 2008 not supported by R2006b, I cannot get support from Mathworks on this issue

Comment only
24 Jun 2010 Reid Reynolds

This was extremely helpful. I had all the problems everyone else has listed. Thanks especially to Dan Knudsen @ 25 Sep 2009.

I had one other issue where I got the error message:

c:\program files (x86)\devstudio\vc\include\win32.mak(61) : fatal error U1050: Must specify CPU environment variable ( CPU=i386, CPU=MIPS, CPU=ALPHA, CPU=PPC)

I'm guessing it is getting something like 'x86' passed to it and doesn't know what to do with it (I am on a Windows platform running Windows XP v2003SP2). I looked up the win32.mak file (why is it win32 and not win64? no idea...) and found the lines

!IF "$(CPU)" == ""
CPU = i386

and commented out the !IF and !ENDIF lines, and was able then to use the accelerator option in SIMULINK.

04 May 2010 marta

marta (view profile)

Thank you! This has been really helpful to me. Worked on Win 64 bit platform, and Matlab R2009b, without having to modify anything in the provided files.

08 Apr 2010 Jeff Evans

Hi all,

I am trying to compile a mex file from a MATLAB function for the first time (win7 x64, MATLAB 2009b). I followed the directions above with modifications posted by Wang, but I get an error. Can anyone suggest what may be wrong?

Thanks for all your great contributions.

Here's the error:

emlmex -d 'D:\myfile' myfun
Warning: The storage type used is an old style. The following file is out of date:
> In CompilerConfigurationFactory>CompilerConfigurationFactory.getBasicStructArray at 189
In CompilerConfigurationFactory>CompilerConfigurationFactory.process at 107
In getCompilerConfigurations at 56
In C:\Program Files\MATLAB\R2009b\toolbox\emlcoder\emlcoder\private\compilerman.p>parse_opts_file at 66
In C:\Program Files\MATLAB\R2009b\toolbox\emlcoder\emlcoder\private\compilerman.p>compilerman at 15
In C:\Program Files\MATLAB\R2009b\toolbox\emlcoder\emlcoder\private\emlckernel.p>emlckernel/compile at 304
In C:\Program Files\MATLAB\R2009b\toolbox\emlcoder\emlcoder\private\emlckernel.p>emlckernel/doit at 135
In C:\Program Files\MATLAB\R2009b\toolbox\emlcoder\emlcoder\private\emlckernel.p>emlckernel at 31
In emlmex at 148
Attempt to reference field of non-structure array.
Use help emlmex for more information on using this command.
??? Error using ==> emlmex

Comment only
25 Feb 2010 Avner Shimron

How do I open and edit the ".stp" files ?

Comment only
09 Feb 2010 Snowred Wang

to get it working with VC2008 standard edition under win 7 64 bit, I did the following change:
1) The file msvc90freematopts.stp on line 51 contains a reference to 'v6.1' change this to 'v6.0a'

2) The file msvc90freematopts.stp line 20,21
-e "$ENV{'VS90COMNTOOLS'}\\..\\..\\VC\\bin\\amd64\\cl.exe" &&
-e "$ENV{'VS90COMNTOOLS'}\\..\\IDE\\VCExpress.exe"){
change to
-e "$ENV{'VS90COMNTOOLS'}\\..\\..\\VC\\bin\\amd64\\cl.exe"){

3) The file msvc90freematopts.stp line 32
$msvc9_root = &$registry_lookup_fcn("SOFTWARE\\Microsoft\\VCExpress\\9.0\\" .
change to
$msvc9_root = &$registry_lookup_fcn("SOFTWARE\\Microsoft\\VisualStudio\\9.0\\" .

4) The file msvc90freematopts.stp line 34
if (-e "$msvc9_root\\VC\\bin\\cl.exe" && -e "$msvc9_root\\Common7\\IDE\\VCExpress.exe"){
change to
if (-e "$msvc9_root\\VC\\bin\\cl.exe"){

5) The environment variable MSSdk needs to be changed to c:\Program Files\Microsoft SDKs\Windows\v6.0a

Comment only
28 Jan 2010 marco

marco (view profile)

Hello, I have windows 7 64bit and matlab 2007b. I installed visual studio C++ express 2008, Download the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 and made the change suggested by Craig Richardson (thank you) but I still get these errors:
"call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\/../../VC/vcvarsall" AMD64 The system cannot find the path specified. "
'nmake' is not recognized as an internal or external command,
operable program or batch file. "

Visual studio 2008 is recognized by mex -setup and the example suggested here works.
what's the value of your enviromental variables MSSDK, VS80COMNTOOLS and VS90COMNTOOLS?

Comment only
05 Dec 2009 Stephen

This was very helpful to me; it finally allowed me to get the Real-Time Workshop working correctly. I did not have to change the reference to 'v6.1', but I am running Matlab R2009a.

I found the easiest way to set the environment variables listed in the 'readme' file was to use the Control Panel. The path through the Control Panel screens is: Control Panel: System: Advanced: Environment Variables.

I am running Matlab R2009a on Windows XP 64 Professional.

03 Dec 2009 Taliana Herrera  
21 Oct 2009 Craig Richardson

I've just installed this on Windows 7 Enterprise, 64-bit with Matlab R2007b. Seems to work ok with mex.

Things that are different from the readme.txt included with the files.
1) Download the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 instead of the version of Windows Server 2008
2) The file msvc90freematopts.stp on line 51 contains a reference to 'v6.1' change this to 'v6.0a'
3) The environment variable MSSdk needs to be changed to c:\Program Files\Microsoft SDKs\Windows\v6.0a

Comment only
25 Sep 2009 Dan Knudsen

Thanks for putting this together, but I can't get it to work.

Granted, I'm on XP 64bit, running 2009a, but when I get to the point of running 'mex -setup' I keep getting the following error: "Undefined subroutine &mexsetup::msvc90freematopts called at C:\PROGRA~1\MATLAB\R2009a\bin\/ line 444. "

One note, I had to change the environment variable: "MSSdk=C:\Program Files\Microsoft SDKs\Windows\v6.1" to "MSSdk=C:\Program Files\Microsoft SDKs\Windows\v6.0A", since 6.0A is what showed up in that location after installing. Maybe this points to a deeper problem I had in installing VCC++ 2008? or maybe this was never meant to work with 2009a?

Any help would be appreciated, thanks!

Comment only
21 Jul 2009 Maja Bitenc

Dear all,

In article 18508 there are two reports (11 Feb 2008, Erik Von Wurstelberg and 25 Apr 2009, Carlos Guerrero Mosquera) that the files do not work for Matlab 7.5 (R2007b) and Windows Vista Business x64 32OS.

Can somebody report if those files by Larry Baker work for the releases described above and Microsoft Visual C++ 2008 Express?!

Thanks a lot for any comment!!!

Comment only
29 Jan 2009 David

David (view profile)

Thank you! This has been incredibly helpful to get VC++ 2008 to correctly compile 64bit mex files with Matlab 2007b (but I still wish Mathworks would officially support gcc under Windows...)

Contact us