MEX - xcodebuild: error: SDK "macosx10.15.4" cannot be located.

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.

 採用された回答

79 belveder
79 belveder 2020 年 3 月 25 日
編集済み: 79 belveder 2020 年 3 月 25 日

29 投票

There seems to be some incompatibility for which I don't know where it comes from. Anyway, the way I got it to work with C/C++ is to
  1. backup (move out otherwise they are not updated properly) any mex_* definition files in /Users/<username>/Library/Application Support/MathWorks/MATLAB/<yourversion>
  2. go to /Applications/<yourmatlab.app>/bin/maci64/mexopts/
  3. edit both clang++_maci64.xml and clang_maci64.xml the following way:
from
<SDKVER>
<cmdReturns name="xcrun -sdk macosx --show-sdk-version"/>
</SDKVER>
to
<SDKVER>
<cmdReturns name="xcrun -sdk macosx --show-sdk-version | cut -c1-5"/>
</SDKVER>
which actually changes 10.15.4 to 10.5 (and does something else apparently).
run
mex -setup C++
mex -setup C
again.
Hth, cheers...

27 件のコメント

Tom Ragonneau
Tom Ragonneau 2020 年 3 月 26 日
Excellent thank you! I tried to modify my mexopts XML by it did not update the others, thank you for the tips. I have done exactly the same thing for the Fortran XML file and it did work. However, for more stability, I changed it to
<SDKVER>
<cmdReturns name="xcrun -sdk macosx --show-sdk-version | cut -d . -f 1,2"/>
</SDKVER>
so that if the length of the version changes in the future, the same code would work.
Thank you!
César Acebes
César Acebes 2020 年 3 月 27 日
Thanks! it worked for me too
Weidong Lin
Weidong Lin 2020 年 3 月 29 日
Many thanks for the tips, it works perfectly.
G R Karthik
G R Karthik 2020 年 3 月 30 日
Awesome ! Worked for me too... Thank you so much !
DICOM
DICOM 2020 年 3 月 30 日
Could you tell me the meanings of cut -d -f?
It did not work for me for C in my mac OS 10.15.4.
Many thanks!
DICOM
DICOM 2020 年 3 月 30 日
Could you please tell me the meaning of '| cut -c1-5'?
It did not work for me.....
79 belveder
79 belveder 2020 年 3 月 30 日
編集済み: 79 belveder 2020 年 3 月 30 日
it actually cuts the first 5 characters from the string 10.14.5, which essentially leaves 10.14 . Are you sure you moved out the old mex files from your user directory and reran setup after fixing the file in the application directory? If you don't remove the old files from the user directory, they are not overwritten.
DICOM
DICOM 2020 年 3 月 30 日
Many thanks! It should have worked, but because of read-only permission of files.
Max Rotunno
Max Rotunno 2020 年 3 月 30 日
Worked for me after I removed the old files
Terrance Nearey
Terrance Nearey 2020 年 3 月 30 日
Worked for me -- but only after reboot of Mac. Thanks everbody every comment helped a bit. Might have given up . Hope Mathworks puts out an official fix. Do they read these things?
Supreeth M
Supreeth M 2020 年 4 月 2 日
I wanted what branch of computer science one needs to know to actually do what you did to give a solution.
Katie Yergert
Katie Yergert 2020 年 4 月 7 日
As a non-computer scientist and new MatLab user, could someone please help me with a few more details?
I have the exact same errors as the original post (see below) but I am struggling to follow the resolution.
First, I have Xcode (v11.4) and MatLab_R2020a installed and I rebooted my computer.
In the resolution, should I be finding these file paths using Finder?
  1. If so, when I open the Mathworks/MATLAB/R2020a folder there are no mex files as far as I can tell.
  2. Regarding step #2 "go to /Applications/<yourmatlab.app>/bin/maci64/mexopts/", I do not see any folder called "bin". I tried searching for it in other ways (including using search field in Finder for "mexopts" and "bin" but was unsuccessful.
Any suggestions would be greatly appreciated! I'm thinking I should uninstall MatLab and reinstall it?
>> toolboxCompile
Compiling.......................................
Building with 'Xcode with Clang'.
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
Error in toolboxCompile (line 35)
for i=1:length(fs), mex([rd '/' ds{i} '/private/' fs{i} '.c'],...
Katie Yergert
Katie Yergert 2020 年 4 月 13 日
I figured out how to access Step 2 in original answer: you have to right click the application and choose "show package contents". Then you can follow the steps.
Could someone please let me know how to do the last step?
run
mex -setup C++
mex -setup C
Is this done in Xcode?
Ruibo Dong
Ruibo Dong 2020 年 4 月 16 日
Could anyone please specify exactly how to do step 1, like, what should I be looking for?
Should I be looking for files ending with .mex_* and delete them?
Many thanks!
Saurav Shenoy
Saurav Shenoy 2020 年 4 月 17 日
/Users/<username>/Library/Application Support/MathWorks/MATLAB/<yourversion>
there is no Mathworks folder in Application support for me, any suggestions?t
Licheng MAO
Licheng MAO 2020 年 4 月 18 日
@Ruibo: The only file on my laptop is "mex_C++_maci64.xml", and it work for me.
@Saurav: Perhaps you didn't put a quote on the path? There is a space between "Application" and "Support"
Ruibo Dong
Ruibo Dong 2020 年 4 月 19 日
Thanks @Licheng but I still couldn't seem to find any of those files in the user directory. There's a bunch of mex_* files in the application directory tho...
I'll just carry on to step 3 to see if this works. However I'm not quite sure where should the "rerun setup" step be done, should I type "mex -setup C++" and "mex -setup C" in a mac terminal? I did that but the terminal returned "zsh: command not found: mex". I think I'm doing this incorrectly, could any one share a bit more details please?
Marcus Ross
Marcus Ross 2020 年 4 月 20 日
Can someone please help with getting started with the fortran compiler. Which file is the "source" file that I need to run in the terminal to invoke the compiler? Any information would help.
emipicrodcm
emipicrodcm 2020 年 4 月 21 日
I applied points 2 and 3 and work.
Marcus Ross
Marcus Ross 2020 年 4 月 22 日
I continually get a message that says the "Did not find installed compiler 'Intel Fortran Composer XE'" anyone experience something similar?
Pengfei
Pengfei 2020 年 4 月 24 日
Genius!
some explanation about step 2&3:open the two files and you can find some sort of codes below:
<SDKVER>
<cmdReturns name="xcrun -sdk macosx --show-sdk-version"/>
</SDKVER>
then change it to:
<SDKVER>
<cmdReturns name="xcrun -sdk macosx --show-sdk-version | cut -c1-5"/>
</SDKVER>
after editting the two files, go to matlab and run:
mex -setup C++
mex -setup C
Marina Saiz Aloa
Marina Saiz Aloa 2020 年 4 月 29 日
Cheers. It worked :)
Xavier Aguas
Xavier Aguas 2020 年 5 月 18 日
Excellent. Thanks for everything
Paulo Gil
Paulo Gil 2020 年 5 月 28 日
Many thanks... it worked!
Ryan Comeau
Ryan Comeau 2020 年 7 月 27 日
Thank you so much.
Baoning Wu
Baoning Wu 2020 年 9 月 9 日
It works for me!
It didn't work initially because I forget to move out the old mex_* file in the /Users/<username>/Library/Application Support/MathWorks/MATLAB/<yourversion>. But it works after I remove those three files.
Lekshmi Dharmarajan
Lekshmi Dharmarajan 2020 年 9 月 29 日
This was a saviour. Thanks!

サインインしてコメントする。

その他の回答 (2 件)

Jin Yan
Jin Yan 2020 年 4 月 14 日
編集済み: Jin Yan 2020 年 4 月 14 日

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 件のコメント

Jiang Zhiping
Jiang Zhiping 2020 年 4 月 15 日
Thanks Jin. That helps me workaround the bug.
Jiang Zhiping
Jiang Zhiping 2020 年 4 月 15 日
my config path is /Users/USRNAME/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C++_maci64.xml
Saurav Shenoy
Saurav Shenoy 2020 年 4 月 17 日
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
Nisha Mohd Rafiq 2020 年 5 月 20 日
me too
Ruoshui Liu
Ruoshui Liu 2020 年 5 月 28 日
Follow upon Jin's suggestion, it worked for me. @Saurav and @Nisha, you coud try this:
  1. compilerCfg = mex.getCompilerConfigurations;
  2. compilerCfg(1).MexOpt = '/Users/<usrname>/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C++_maci64.xml';
  3. compilerCfg(2).MexOpt = '/Users/<usrname>/Library/Application Support/MathWorks/MATLAB/R2020a/mex_C_maci64.xml';
  4. Open those 2 files and update SDKVER with suggestions above for both C++ and C;
  5. Rerun mex -setup C++ and mex -setup C
Hope it works for you!
Thanks!
A.B.
A.B. 2020 年 6 月 8 日
編集済み: A.B. 2020 年 6 月 8 日
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.
A.B.
A.B. 2020 年 6 月 8 日
編集済み: A.B. 2020 年 6 月 8 日
This is one of the many reasons why matlab is going down and python is taking its place.

サインインしてコメントする。

Paul
Paul 2020 年 4 月 13 日

0 投票

Thanks! Genius.

カテゴリ

ヘルプ センター および File ExchangeMATLAB Compiler についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by