I would like to use the Microsoft Visual C++ 2003 Toolkit with the MATLAB Compiler 4.0 (R14).
MATLAB: Can I use the Microsoft Visual C++ 2003 Toolkit with MATLAB Compiler 4.0 (R14)
2003ccompilerMATLAB Compilerprofessionaltoolkitvisual
Related Solutions
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
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>
This can happen if Microsoft Visual Studio Visual C++ compiler is installed in a non-default directory. The mex options file looks for MSVC 8.0 in a directory relative to the environment variable VS80COMNTOOLS and MSVC 7.1 in a directory relative to the environment variable VS71COMNTOOLS.
You can find out what this environment variable is set to by using the following command at the MATLAB command prompt
getenv VS80COMNTOOLS
or
getenv VS71COMNTOOLS
If the environment variable for the appropriate compiler does not exist, you will need to either re-install Microsoft Visual Studio or create the environment variable manually. It needs to point to the Common7\Tools\ sub directory of your Microsoft Visual Studio installation. This is often located at:
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
or
C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\
Microsoft Visual C++ should be installed in a directory called “VC” (for MSVC 8.0) or "VC7" (for MSVC 7.1). This directory should be located two directories above the directory specified by VS80COMNTOOLS or VS71COMNTOOLS. If this is not the case, the setup will not be able to locate your compiler automatically. For example if VS80COMNTOOLS is set to:
C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\
then Microsoft Visual C++ is expected to be located at
C:\Program Files\Microsoft Visual Studio 8\VC
You can either re-install Microsoft Visual Studio in this arrangement or do the following (example given for MSVC 8.0):
1. When prompted: "Would you like mex to locate installed compilers [y]/n?" type "n".
2. Select "Microsoft Visual C/C++ version 8.0"
3. When prompted: "Use C:\Program Files\Microsoft Visual Studio 8 anyway [y]/n?" type "n"
4. Enter the correct path to Microsoft Visual Studio, i.e. "C:\MYCOMPILERDIR\Microsoft Visual Studio 8".
Related Question
- Does the Real-Time Workshop support Microsoft Visual Studio 2005 C/C++ compilers
- Selective/partial unistall of Microsoft Visual Studio C++ compiler for mexFunction
- How to get the current configured mbuild compiler
- How to embed a manifest file into a DLL or EXE created using the MATLAB Compiler 4.9 (R2008b)
Best Answer