I am trying to use the MATLAB Function block in R2011b. When I try to run my program, this is the error I am getting:
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler.
When I try doing mex -setup
, I get the following output:
>> mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2011b/win64.html
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: 1
Warning: The default location for Intel C++ compiler is:
"C:\Program Files (x86)\Intel\ComposerXE-2011"
but either that directory does not exist or the configuration
is invalid.
Use C:\Program Files (x86)\Intel\ComposerXE-2011 anyway [y]/n? y
Please verify your choices:
Compiler: Intel C++ 12.0
Location: C:\Program Files (x86)\Intel\ComposerXE-2011
Are these correct [y]/n? y
Error: Microsoft Visual Studio 2008 SP1 Professional Edition was not found
by mex -setup.
The Microsoft Visual Studio 2008 SP1 Professional Edition linker is
required to build Intel C++ MEX-files. Please make sure that
Microsoft Visual Studio 2008 SP1 Professional Edition is installed
properly.
Error using mex (line 206)
Unable to complete successfully.
Whatever compiler I choose, I get the same error. Which compiler do I need to select, or is there another problem?
By examining your comments, first we have asked you to choose the yes option to see whether or not your computer has any valid compilers installed. You have chosen that and it cannot locate any valid compilers. As such, you don't have any compilers installed on your computer.
Usually if you want to compile MEX files in Windows, you need a Microsoft Visual Studio compiler to allow you to do this. To obtain this, I have four solutions for you depending on what is available to you:
Good luck!