MATLAB: Can I use the Microsoft Visual C++ 2003 Toolkit with the MEX command for MATLAB 7.0 (R14)

2003ccompilerMATLABmexmicrosofttoolkitvisual

I would like to use the Microsoft Visual C++ 2003 Toolkit with the MEX command for MATLAB 7.0 (R14) and above.

Best Answer

The Microsoft Visual C++ 2003 Toolkit is not a supported compiler for use with MATLAB. For a complete list of supported compilers please visit the following web page:
The following instructions can enable you to work around this issue. However, since this is not a supported compiler, it has not been tested and technical support is not available.
In addition to installing Microsoft Visual C++ 2003 Toolkit, you will also need two additional packages before the Microsoft Visual C++ 2003 Toolkit can be used to create MEX functions from C source files. These packages are:
1. Microsoft Platform SDK
2. Microsoft .NET Framework SDK 1.1
These can be downloaded from http://www.microsoft.com/
To use the Microsoft Visual C++ 2003 Toolkit to compile MEX functions perform the following steps:
1. The Microsoft Visual C++ 2003 toolkit does not ship with msvcrt.lib file which is required at link time. Installing the .NET Framework 1.1 SDK copies the msvcrt.lib file to "..\Microsoft Visual Studio .NET 2003\Vc7\lib". Copy this file to the "lib" folder in the MSVC++ 2003 Toolkit directory or the "lib" folder under the Platform SDK installation folder.
2. Download the options file msvc2003toolkit.bat from the link below. This file is a modified version of the MATLAB 7.2 (R2006a) Microsoft Visual C++ 7.1 options file. If you are using a different version of MATLAB, additional modifications besides the ones listed below may be required. You can find the original options file for your copy of MATLAB at $MATLABROOTbin\win32\mexopts\msvc71opts.bat (where $MATLABROOT is the MATLAB root directory on your machine, as returned by typing:
matlabroot
at the MATLAB command prompt.)
3. Change lines 14 and 15 to reflect the installation folders of the Microsoft Visual C++ 2003 Toolkit and the Platform SDK on your machine.
4. To compile your MEX-function use the following command:
mex -f <path to options file>\msvc2003toolkit.bat <C source file>
Alternately, you can rename the downloaded options file to "mexopts.bat" and copy it to your preference directory. The preference directory can be found by issuing the following command at the MATLAB Command Prompt:
prefdir
Then you can use the MEX command as:
mex <C source file>