0
votes

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?

1
One thing you need to do is you should let MEX locate your valid compilers. Choosing No (n) will simply list every single possible compiler that is known for Windows. Choose Yes (y) and let us know which compilers are actually installed.rayryeng
says-No supported SDK or compiler was found on this computer.Mojo Jojo

1 Answers

1
votes

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:

  1. If you are a student in a post-secondary institution, try going to Microsoft DreamSpark: https://www.dreamspark.com/Product/Product.aspx?productid=72&cmpid=W_VS_DSV_DS_728x90_ENG . Your institution may have an agreement with Microsoft, and you'll be able to download Microsoft Visual Studio for free. Seeing as how you are using MATLAB R2011, support up to Visual Studio 2010 is supported. As such, make sure you choose 2010 as the version.
  2. You can try a 90-day trial of Microsoft Visual Studio in case (1) doesn't pan out for you: http://www.visualstudio.com/
  3. You can buy Microsoft Visual Studio in case (1) doesn't pan out for you - use the link in (2)
  4. Use Microsoft Visual Studio Express (this is FREE) - http://www.visualstudio.com/en-us/downloads/download-visual-studio-vs#DownloadFamilies_4 . Make sure you choose Visual C++ 2010 Express. This is essentially a trimmed down version of Microsoft Visual Studio. I am not sure what is available in this distribution, but most of the functionality that is seen with the full version of Microsoft Visual Studio is present. I do know that this is fully compatible with MATLAB R2011, so you shouldn't have a problem getting it running. My suspicion is that you will probably use this approach, and that's totally fine. You also need to download the Windows SDK as well: http://www.microsoft.com/en-us/download/details.aspx?id=8279

Good luck!