Mex files and compiler

44 views (last 30 days)
Hello everyone,
I have trouble to execute mex files and to set up my compiler...
My MatLab version is R2011b, so according to this page, it should support the following compilers (that I have): Microsoft Windows SDK 7.1 (with .NET Framework 4.0) and Microsoft Visual C++ 2010 Express.
When I use the command mex -setup, I can select the visual c++ compiler for example, and it seems to work just fine (see a copy of it at the end of this post). But after that, when I want to use it, here what I get :
>> mex hello.cpp Error: Could not find the compiler "cl" on the DOS path.
Use mex -setup to configure your environment properly.
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Unable to locate compiler.
Error using mex (line 206)
Unable to complete successfully.
I read a lot on the internet but unsuccessfully, I did not find any solution for my current problem... Do you think it is about the note 3 at the end of the page of the previous link ? Or because I run a 64 bits machine ?
For information, here is what I have by using the mex -setup command :
>> mex -setup
Welcome to mex -setup. This utility will help you set up a default compiler. For a list of supported compilers, see
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? n
Select a compiler:
[1] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker)
[2] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker)
[3] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker)
[4] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker)
[5] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker)
[6] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker)
[7] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker)
[8] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker)
[9] Microsoft Software Development Kit (SDK) 7.1
[10] Microsoft Visual C++ 2005 SP1
[11] Microsoft Visual C++ 2008 SP1
[12] Microsoft Visual C++ 2010
[13] Microsoft Visual C++ 2010 Express
[0] None
Compiler: 13
Your machine has a Microsoft Visual C++ 2010 Express compiler located at C:\Program Files (x86)\Microsoft Visual Studio 10.0. Do you want to use this compiler [y]/n? y
Please verify your choices:
Compiler: Microsoft Visual C++ 2010 Express Location: C:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
Trying to update options file: C:\Users\Antoine\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat From template: C:\PROGRA~1\MATLAB\R2011b\bin\win64\mexopts\msvc100freeopts.bat
Done . . .
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
Building with the -largeArrayDims option enables the new API.
Or again :
>> mex.getCompilerConfigurations()
ans =
Package: mex
Name: 'Microsoft Visual C++ 2010 Express'
Manufacturer: 'Microsoft'
Language: 'C++'
Version: '10.0'
Location: 'C:\Program Files (x86)\Microsoft Visual Studio 10.0'
Details: [1x1 mex.CompilerConfigurationDetails]
If someone could enlight me a little bit, that would be great !
Thank you
Edoardo Alberti
Edoardo Alberti on 4 Mar 2013
Dear Antoine, I am facing the same issue as you are doing.. my matlab says
" Error: The Microsoft Windows Software Development Kit (SDK) installation is incomplete. Please be sure that the .NET Framework is installed correctly before attempting to reinstall the SDK. "
could you indicate what is the installation sequence that you adopted? I already uninstalled and re-installed following your suggestion to restart the machine, but apparently I am still doing something not correct.. thanks Edo

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 20 Feb 2013
Image Analyst
Image Analyst on 4 Mar 2013
If you're done with the topic, then you click the "Accept this Answer" link.

Sign in to comment.

More Answers (1)

Ulzii on 8 Jun 2013
Hi guys. i have same problem like your problem. Did you solve it?. if solved already, how could you solve it ? /sorry my English not good/
thanks Ulzii
Kaustubha Govind
Kaustubha Govind on 10 Jun 2013
Is your error the same as the original one "Error: Could not find the compiler "cl" on the DOS path."? You didn't mention the full error message that you're seeing.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!