Why do I receive an error message regarding the "cl" compiler on the DOS path when compiling and linking engine programs with MATLAB 7.0.4 (R14SP2)?
8 views (last 30 days)
Show older comments
When I compile and link MATLAB Engine programs, MATLAB cannot find the compiler.
For example, type the following at the MATLAB command prompt:
optsFile = fullfile(matlabroot,'bin','win32','mexopts','msvc71engmatopts.bat');
compFile = fullfile(matlabroot,'extern','examples','eng_mat','engwindemo.c');
mex(compFile,'-f',optsFile)
The following error message occurs:
Could not find the compiler "cl" on the DOS path.
Use mex -setup to configure your environment properly.
D:\APPLICATIONS\MATLAB704\BIN\WIN32\MEX.PL: Error: Unable to locate compiler.
??? Error using ==> mex
Unable to complete successfully
Accepted Answer
MathWorks Support Team
on 11 Jun 2013
This error message is seen if the environment variable, MSVCDir, does not point to the correct location of the Visual Studio Installation.
To solve the issue, set MSVCDir to the ACTUAL location of your MSVC install as follows:
1. Make a copy of the "msvc71engmatopts.bat" file in the current working directory. Note that the "msvc71engmatopts.bat" file can be found under $MATLABROOT\bin\win32\mexopts\msvc71engmatopts.bat, where $MATLABROOT is the installation directory of MATLAB 7.0.4 (R14SP2). Also note that this file may not exist in those versions of MATLAB which do not support Microsoft Visual Studio .NET 2003.
2. Open the file in a text editor. In line 13, change the "MSVCDir" variable from:
set MSVCDir=%MSVCDir%
to:
set MSVCDir=C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7
(where C:\Program Files is the directory that contains Microsoft Visual Studio .NET 2003)
In general, the directory is usually something like:
C:\Program Files\Microsoft Visual Studio <version>\VC<version>
In some versions of Visual Studio, the "VC" folder does not have a version number. The correct directory will contain a "bin" folder which is where the compiler is located (CL.EXE).
0 Comments
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!