MATLAB Answers

2

Can I use Xcode 5 as my C or C++ compiler in MATLAB 8.1 (R2013a) or MATLAB 8.2 (R2013b)?

I want to use one of the later versions of Xcode as my C compiler in MATLAB 8.1 (R2013a) or MATLAB 8.2 (R2013b); however, I get the error
xcodebuild: error: SDK "macosx10.7" cannot be located
when using MEX with Xcode 5. Is it possible to use Xcode 5 when using MEX?

Tags

No tags entered yet.

Products


Release

R2013b

2 Answers

Answer by MathWorks Support Team on 24 Oct 2013
 Accepted Answer

The Mac OS X 10.7 SDK, available in Xcode 4.1 through 4.6, is used by MEX and related capabilities. This SDK is no longer available in Xcode 5, resulting in errors similar to the following when compiling:
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
The simplest solution is to avoid updating Xcode to version 5 if you are using R2013a or R2013b. If you need Xcode 5, or you have already irreversibly upgraded to it, you can update MEX to use the 10.8 SDK:
1. In the MATLAB Command Window, execute the following commands:
cd(matlabroot)
cd bin
edit mexopts.sh
2. Save a backup copy of this file somewhere in case you make a mistake and you need to revert your changes.
3. Scroll down to the Mac (“maci64”) section of this file, beginning around line 120.
4. Replace all instances of 10.7 with 10.8; there are four of these in all (a fifth may be found in comments only)
5. Save the file, then execute the following command in the MATLAB Command Window:
mex -setup
Please note that this workaround links MEX files with a different SDK than with which MATLAB was tested. Although there are no known compatibility issues, support may be limited.

  5 Comments

In my case i used Xcode 5.1.1 and MacOSX10.9. When using Xcode 5.1 the error
"In file included from test.c:2: In file included from /Applications/MATLAB_R2013a.app/extern/include/matrix.h:295: /Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown type name 'char16_t' typedef char16_t CHAR16_T; ^ 1 error generated."
emerged. But when i added
"-Dchar16_t=uint16_t"
to the CFLAGS at the same maci64 section of the mexopts.sh as follows
CFLAGS="-fno-common -arch $ARCHS -isysroot $MW_SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -Dchar16_t=UINT16_T"
everything seemed to work very well after compiling.
Hello. I am now running XCode 6.4 and on OSX 10.10.5. I have this same issue with the SDK so I replaced all 10.7 for 10.10 on mexopts.sh and got the same error you have above. I already tried adding "-Dchar16_t=uint16_t" but this won't do the trick for me. Any thoughts?
Me again. I added "-Dchar16_t=UINT16_T" instead of "-Dchar16_t=uint16_t" and this worked properly.

Sign in to comment.


Answer by Onkar Manjrekar on 28 Oct 2015

I am trying to install libsvm to matlab. I have Xcode 5 unfortunately, I did above steps and still get the same error. What can I do?
Thank you in advance.
Regards, Onkar

  1 Comment

Onkar, could you expand on which error is "the same error" in your situation?
Which MATLAB release are you using, and which operating system?

Sign in to comment.