Asked by MathWorks Support Team
on 2 Oct 2015

I installed Xcode 7.0 on my Mac and tried to use MEX. I receive the following error at the MATLAB command prompt:

>> mex -setup Error using mex No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2015a/maci64.html

Why does MATLAB not recognize the Xcode 7.0 installation on my Mac?

Answer by MathWorks Support Team
on 28 Aug 2017

Edited by MathWorks Support Team
on 28 Aug 2017

Accepted Answer

By default, MATLAB R2015b does not detect Xcode 7.x. To add support for Xcode 7.x in MATLAB R2015b, download the files attached to this article. Please follow these instructions to download and install the files (screenshots were taken in Mac OS X 10.10.5 Yosemite):

1) Download the file xcode7_mexopts.zip, which you will find attached to this article. Extract the contents of xcode7_mexopts.zip to your Downloads directory. Extracting the ZIP file will create a directory in Downloads called xcode7_mexopts.

2) Open MATLAB R2015b. Navigate to MATLAB's preference directory by typing the following command in the command window:

>> cd( prefdir );

3) Using MATLAB's "Current Folder" browser, ensure that there are no XML files that begin with "mex_" (e.g. mex_C_maci64.xml). If such files exist, remove them from the preference directory.

4) Navigate to the MATLAB directory. In MATLAB, you can do so by entering the following command at the MATLAB command prompt:

>> cd( fullfile( matlabroot, 'bin', 'maci64', 'mexopts' ) );

5) Back up the original files in the mexopts directory. You can run the following MATLAB commands to back up the files:

>> mkdir mexoptsContentsOLD >> movefile *.xml mexoptsContentsOLD/

Keep the backup separate from the downloaded files such that you can revert to the backup files if necessary.

6) Replace any files in the mexopts directory with the corresponding files in the Downloads folder, xcode7_mexopts. You can replace the files in MATLAB by entering the following command at the MATLAB command prompt:

>> movefile( '~/Downloads/xcode7_mexopts/*.xml', '.' );

7) Restart MATLAB R2015b. Execute "mex -setup" at the MATLAB command prompt as shown below and verify that MEX detects Xcode 7.0.

>> mex -setup

Alternate Solution:

The SDK needed could be in the Xcode package with the path:

/Applications/XCODE/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

Please place this in:

/Library/Developer/CommandLineTools/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

This should resolve the issue.

If MEX continues to return an error, please contact MathWorks Technical Support.

Answer by Chun-Hsien Lin
on 27 Nov 2015

I found this workaround. It works for me.

Hsi-Ming Chang
on 31 Mar 2016

Thank you. This solved my problem.

Marcel Goldschen
on 10 Jun 2016

Yup, this worked for me too. Thanks.

Log in to comment.

Answer by XIE STONE
on 21 Sep 2016

I try and it did not work for me. :(

Any good idea?

Jianyang Shi
on 18 Apr 2017

Perfect! Thanks.

Darshan Patil
on 27 Apr 2017

Thanks!

lio jello
on 29 May 2017

it really works, thanks

Log in to comment.

Answer by Hamid Sarfraz
on 25 Feb 2016

Edited by Hamid Sarfraz
on 25 Feb 2016

mex -setup

MEX configured to use 'Xcode with Clang' for C language compilation.

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: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

To choose a different language, select one from the following:

mex -setup C++

mex -setup FORTRAN

MEX configured to use 'Xcode Clang++' for C++ language compilation.

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: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

Error using mex

No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2015b/maci64.html.

any explanation(solution) for this ?

Esha Bhargava
on 4 May 2016

If the workaround provided above does not work for you, please contact MathWorks Technical Support.

Log in to comment.

Answer by Brigitte Reniers
on 1 Mar 2016

Edited by Walter Roberson
on 2 Mar 2016

I did all that and I still get this error:

mex Gamma4DCPU.cpp Building with 'Xcode Clang++'. Error using mex /Users/brigitte/Documents/SmartScientificSolutions/Code/Gamma4D/Gamma4DCPU.cpp:111:10: fatal error: 'malloc.h' file not found #include <malloc.h> ^ 1 error generated.

Does anybody know what it's about?

Xiaoyu Sun
on 30 Mar 2016

I also get this error.did you solve this problem successfully?

Log in to comment.

Answer by Pascal
on 30 Mar 2016

worked for me. Perfectly. Thanks

Richa Gupta
on 25 Apr 2016

If the workaround provided above does not work for you, please contact MathWorks Technical Support.

Log in to comment.

Answer by Wichchuwon Sookchaisri
on 7 May 2016

really thanks! It works!

Log in to comment.

Answer by cihat tek
on 18 May 2016

for windows ?

>> mex -setup Error using mex No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2015a/maci64.html.

Walter Roberson
on 18 May 2016

The error message suggests you are on OS-X but your question has to do with MS Windows?

For OS-X you should follow the instructions above.

Log in to comment.

Answer by Hitham
on 13 Jun 2016

Edited by David
on 18 Jan 2017

I have the same problem. I am using MATLAB R2014b (It is said, No supported compiler or SDK was found. For options, visit http://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/SystemRequirements-Release2014b_SupportedCompilers.pdf ).

How to fix it?

Esha Bhargava
on 17 Jun 2016

If the workaround provided above does not work for you, please contact MathWorks Technical Support.

Vandana Ravichandran
on 22 Feb 2017

Log in to comment.

Answer by Bhavesh Dharmani
on 27 Jun 2016

I have installed just the Xcode command line tools and it is installed at /Library/Developer/CommandLineTools. So, whether the same solution will work for me?

I have also changed [matlabroot '/bin/maci64/mexopts/clang_maci64.xml'] and [matlabroot '/bin/maci64/mexopts/clang++_maci64.xml'] to search corresponding to mac OSX 10.11. But, nothing works to setup mex.

Richa Gupta
on 21 Jul 2016

Bhavesh, I would suggest contacting MathWorks Technical Support.

Log in to comment.

Answer by viktor navorski
on 24 Jul 2016

Thank you. The problem was solved on OS X 10.11.6 (15G31)

Log in to comment.

Answer by ahmed ali
on 29 Sep 2016

i want to ask about the detailed steps to download minGW-compiler for mex files for matlab 2015b

Walter Roberson
on 7 Oct 2016

Anudeep Katragadda
on 21 Oct 2016

Log in to comment.

Answer by Fateh Benma
on 24 Jun 2017

i have this error !! why ?? any help >> mex -setup Warning: Xcode appears to be installed, but it has not been configured. Run "osascript -e 'do shell script "xcode-select -switch /Applications/Xcode.app" with administrator privileges'" to configure Xcode. You must be an administrator of this computer to complete this action.

Error using mex No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2014a/win64. >>

Log in to comment.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 18 Comments

## Erik Reinertsen (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_319457

These instructions solved my problem. Thank you so much!

## Derek Gaston (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_321011

Unfortunately, this isn't working for me on OSX 10.11.1 with XCode 7.1

## yun-chih chou (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_321526

Same solution for Matlab R2014b to detect Xcode7.1 on OSX 10.11.1. Thanks.

## Cuong Pham (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_322975

That worked for me. Thank you!

## Brian Chow (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_325019

This worked for me. Thank you!

## Orhan (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_326986

I tried this on R2014 and it worked. Great directions!

## N Kando (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_329820

Worked for me perfectly.

## Rajat Singhal (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_332689

Well explained.. Worked for me! Thanks!

## Joseph Cullen (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_335894

No go. Still has the same problem.

## Rashwan Almshaal (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_345405

Very helpful, thanks a lot

## Alexandre Donze (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_348351

For some reason I had to reset Xcode command line tools path with:

Try this if it still does not work for you.

## Ewelina Zatorska (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_356062

This worked in my case. Thanks!

## Amod Agrawal (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_398004

Please update this answer for macOS Sierra, XCode 8 and Matlab 2015b. Thanks!

## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_398016

Arnod Agrawal, see http://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_392485

## Amod Agrawal (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_398080

Thanks! This worked.

## Shuai Yuan (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_434406

Walter Roberson, I tried this for macOS Sierra, Xcode 8.0 and Matlab 2016a, but it didn't work. What should I do? Thanks!

## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_457556

See https://www.mathworks.com/matlabcentral/answers/303369-mex-cannot-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-8-0#answer_235135 if you want my step-by-step instructions on doing this yourself. See https://www.mathworks.com/matlabcentral/answers/243868-mex-can-t-find-compiler-after-xcode-7-update-r2015b#comment_454130 if you want my edited files that have been recently tested for R2016a on MacOS Sierra with the latest XCode.

## Elco Bakker (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/246507-why-can-t-mex-find-a-supported-compiler-in-matlab-r2015b-after-i-upgraded-to-xcode-7-0#comment_488726

This didn't work for me (matlab 2015b, Mac OS 10.12.6 (16G29) ) but this answer did (with the modification that I had to put a '13' in the file name instead of a '12').

Log in to comment.