Setu Kumar Basak
Setu Kumar Basak

Reputation: 12022

How to locate compiler for mex in matlab?

I want to run c code from Matlab. So i started to google and saw that using mex, i can achieve it. But i got problem to run mex in matlab. Here's what i did:

1. At first i ran mex -setup in matlab command window.

2. Then i got the below response.

Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n?

3. I wrote y and got below response

No supported SDK or compiler was found on this computer. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2013a/win64.html

4. I went to the link and downloaded the sdk and installed it in my windows 10. But while installing i got some problem but continued.

enter image description here

5. Again repeated the whole process and wrote y but got same message as above.

6. Then i tried by writing n and saw all the list of my compilers.

[1] Intel C++ 13.0 (with Microsoft Software Development Kit (SDK) linker) 
[2] Intel C++ 13.0 (with Microsoft Visual C++ 2010 linker) 
[3] Intel C++ 13.0 (with Microsoft Visual C++ 2012 linker) 
[4] Intel C++ 12.0 (with Microsoft Software Development Kit (SDK) linker) 
[5] Intel C++ 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
[6] Intel C++ 12.0 (with Microsoft Visual C++ 2010 linker) 
[7] Intel C++ 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
[8] Intel Visual Fortran 13 (with Microsoft Software Development Kit (SDK) linker) 
[9] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2010 linker) 
[10] Intel Visual Fortran 13.0 (with Microsoft Visual C++ 2012 linker) 
[11] Intel Visual Fortran 12 (with Microsoft Software Development Kit (SDK) linker) 
[12] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 SP1 linker) 
[13] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2008 Shell linker)
[14] Intel Visual Fortran 12.0 (with Microsoft Visual C++ 2010 linker) 
[15] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 SP1 linker) 
[16] Intel Visual Fortran 11.1 (with Microsoft Visual C++ 2008 Shell linker) 
[17] Microsoft Software Development Kit (SDK) 7.1
[18] Microsoft Visual C++ 2005 SP1 
[19] Microsoft Visual C++ 2008 SP1 
[20] Microsoft Visual C++ 2010 
[21] Microsoft Visual C++ 2012 

7. The number 17 is my installed sdk. so i got a response after selecting 17.

Warning: The default location for Microsoft Software Development Kit (SDK) compiler is: "C:\Program Files (x86)\Microsoft Visual Studio 10.0" but either that directory does not exist or the configuration is invalid.

8. I have uninstalled visual studio from my computer and that directory remained

Is there any easy way to run c file from matlab or how to install compiler for mex file ??

EDIT: Now what i found is Windows Software Development Kit (SDK) for Windows 10 from this link and downloading it. I don't know that it will work or not??

Upvotes: 0

Views: 1496

Answers (1)

Blue Bird
Blue Bird

Reputation: 318

I can not remember how many times that I close with striking MEX files. The following way is time-consuming but effective.

  1. Uninstall Visual Studios and SDKs from your computer.
  2. Find a supported version of Visual Studio from ‘https://www.mathworks.com/support/compilers.html
  3. Install C++ and related libraries in this Visual Studios with default directory. Do not try to choose libraries by yourself.
  4. Run ‘mex -setup’, and let it find the compiler.

The entire process will use up a whole morning with good luck.

Upvotes: 1

Related Questions