MEX - xcodebuild: error: SDK "macosx10.15.4" cannot be located.
Show older comments
I installed Xcode (11.4) and Intel Fortran Composer XE (19.1.0.166) on my machine (macOS Catalina 10.15.4) and since the macOS update, mex does not work anymore. I can run
mex -setup -v FORTRAN
which works and returns
Verbose mode is on.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Looking for environment variable 'IFORT_COMPILER17' ...No.
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
... Looking for folder '/opt/intel/compilers_and_libraries_2020.0.166/mac/bin/intel64' ...Yes.
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Looking for environment variable 'IFORT_COMPILER17' ...No.
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
... Looking for folder '/opt/intel/compilers_and_libraries_2020.0.166/mac/compiler/lib' ...Yes.
... Executing command 'ifort --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -1' ...Yes ('19.1.0').
... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk').
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('11.4').
... Executing command '
agreed=11.4
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('11.4').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Executing command 'find /Applications/Xcode.app/Contents/Developer -name libclang_rt.osx.a' ...Yes ('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin/libclang_rt.osx.a').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.15.4').
Found installed compiler 'Intel Fortran Composer XE'.
... Looking for compiler 'Intel Fortran Composer XE' ...
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Looking for environment variable 'IFORT_COMPILER17' ...No.
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
... Looking for folder '/opt/intel/compilers_and_libraries_2020.0.166/mac/bin/intel64' ...Yes.
... Looking for environment variable 'IFORT_COMPILER19' ...No.
... Looking for environment variable 'IFORT_COMPILER18' ...No.
... Looking for environment variable 'IFORT_COMPILER17' ...No.
... Looking for environment variable 'IFORT_COMPILER16' ...No.
... Looking for environment variable 'IFORT_COMPILER15' ...No.
... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
... Looking for folder '/opt/intel/compilers_and_libraries_2020.0.166/mac/compiler/lib' ...Yes.
... Executing command 'ifort --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' | head -1' ...Yes ('19.1.0').
... Executing command 'xcrun -sdk macosx --show-sdk-path' ...Yes ('/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk').
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('11.4').
... Executing command '
agreed=11.4
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi' ...Yes ('11.4').
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Executing command 'find /Applications/Xcode.app/Contents/Developer -name libclang_rt.osx.a' ...Yes ('/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin/libclang_rt.osx.a').
... Looking for folder '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.15.4').
Found installed compiler 'Intel Fortran Composer XE'.
MEX configured to use 'Intel Fortran Composer XE' for FORTRAN language compilation.
However, when I launch the compilation, I get the following error
Error using mex
xcodebuild: error: SDK "macosx10.15.4" cannot be located.
xcrun: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk macosx10.15.4 -find clang 2> /dev/null' failed with
exit code 16384: (null) (errno=No such file or directory)
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
Also, the command
xcode-select --print-path
returns as expected
/Applications/Xcode.app/Contents/Developer
I tried to switch the path to
sudo xcode-select --switch /Library/Developer/CommandLineTools
but I is even worse since I cannot even setup mex.
Does anyone have encounter a similar error? Thank you.
Accepted Answer
More Answers (2)
79 belveder's answer is correct, but I failed firstly.
Additionaly, in step 2, you need to run
mex.getCompilerConfigurations
to get your mex configuration path. Remember that your conf. path is not always '/Applications/<yourmatlab.app>/bin/maci64/mexopts/'.
It seems like the output of 'xrun' in macOS Catalina is 10.15.4 rather than 10.15, but you only have the sdk version of 10.15. I guess it's a bug of Catalina.
7 Comments
Jiang Zhiping
on 15 Apr 2020
Thanks Jin. That helps me workaround the bug.
Jiang Zhiping
on 15 Apr 2020
my config path is /Users/USRNAME/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C++_maci64.xml
Saurav Shenoy
on 17 Apr 2020
after running mex.getCompilerConfigurations, what do we do after that? I tried editing the files from belveder's answer but I get the same exact error message, so it did not seem to update the 10.15.4 to 10.15
Nisha Mohd Rafiq
on 20 May 2020
me too
Ruoshui Liu
on 28 May 2020
Follow upon Jin's suggestion, it worked for me. @Saurav and @Nisha, you coud try this:
- compilerCfg = mex.getCompilerConfigurations;
- compilerCfg(1).MexOpt = '/Users/<usrname>/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C++_maci64.xml';
- compilerCfg(2).MexOpt = '/Users/<usrname>/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C_maci64.xml';
- Open those 2 files and update SDKVER with suggestions above for both C++ and C;
- Rerun mex -setup C++ and mex -setup C
Hope it works for you!
Thanks!
Apple is really an aweful ecosystem. So is MATLAB when used on Apple systems. Why should the end users go through so much agony and turture of reconfiguring so many things manually with every update of macOS or MATLAB? Everything was functional after weeks of work on setting things up. and now with one automatic update by macOS, matlab mex is not working at all. and the torture begins again.
none of the solutions here worked in my case, as others mention here: https://www.mathworks.com/matlabcentral/answers/513349-loadlibrary-mac-os-10-15-4-and-matlab-2020a-gives-can-t-find-correct-sdk
This is one of the many reasons why matlab is going down and python is taking its place.
Paul
on 13 Apr 2020
0 votes
Thanks! Genius.
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!