NLMF function mex compile error on Mac

4 ビュー (過去 30 日間)
Jason
Jason 2020 年 10 月 9 日
回答済み: Srinivas Gorur Shandilya 2020 年 11 月 17 日
Hello,
I downloaded and am trying to use the non-local means noise filtering.
I learned that I need to complie some of the .c files as follows:
% First Compile c-code!!!!, with :
% mex vectors_nlmeans_single.c -v
% mex image2vectors_single.c -v
% mex vectors_nlmeans_double.c -v
% mex image2vectors_double.c -v
But I keep failing it with errors.
>> mex vectors_nlmeans_single.c -v
Verbose mode is on.
... Looking for compiler 'Xcode with Clang' ...
... Looking for environment variable 'DEVELOPER_DIR' ...No.
... Executing command 'xcode-select -print-path' ...Yes ('/Applications/Xcode.app/Contents/Developer').
... Looking for folder '/Applications/Xcode.app/Contents/Developer' ...Yes.
... Executing command 'which xcrun' ...Yes ('/usr/bin/xcrun').
... Looking for folder '/usr/bin' ...Yes.
... Executing command 'defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...No.
... Executing command 'defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense' ...Yes ('11.0').
... Executing command '
agreed=11.0
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.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 'xcrun -sdk macosx --show-sdk-version' ...Yes ('10.15.6').
Found installed compiler 'Xcode with Clang'.
Options file details
-------------------------------------------------------------------
Compiler location: /Applications/Xcode.app/Contents/Developer
Options file: /Applications/MATLAB_R2017a.app/bin/maci64/mexopts/clang_maci64.xml
CMDLINE200 : /usr/bin/xcrun -sdk macosx10.15.6 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map" /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.o /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/c_mexapi_version.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/c_exportsmexfileversion.map" -L"/Applications/MATLAB_R2017a.app/bin/maci64" -lmx -lmex -lmat -lc++ -o vectors_nlmeans_single.mexmaci64
CC : /usr/bin/xcrun -sdk macosx10.15.6 clang
CXX : /usr/bin/xcrun -sdk macosx10.15.6 clang++
DEFINES : -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE
MATLABMEX : -DMATLAB_MEX_FILE
MACOSX_DEPLOYMENT_TARGET : 10.9
CFLAGS : -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
INCLUDE : -I"/Applications/MATLAB_R2017a.app/extern/include" -I"/Applications/MATLAB_R2017a.app/simulink/include"
COPTIMFLAGS : -O2 -fwrapv -DNDEBUG
CDEBUGFLAGS : -g
LD : /usr/bin/xcrun -sdk macosx10.15.6 clang
LDXX : /usr/bin/xcrun -sdk macosx10.15.6 clang++
LDFLAGS : -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map"
LDBUNDLE : -bundle
FUNCTIONMAP : "/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map"
VERSIONMAP : "/Applications/MATLAB_R2017a.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKEXPORT : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map"
LINKEXPORTVER : -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/c_exportsmexfileversion.map"
LINKLIBS : -L"/Applications/MATLAB_R2017a.app/bin/maci64" -lmx -lmex -lmat -lc++
LDOPTIMFLAGS : -O
LDDEBUGFLAGS : -g
OBJEXT : .o
LDEXT : .mexmaci64
SETENV : CC="/usr/bin/xcrun -sdk macosx10.15.6 clang"
CXX="/usr/bin/xcrun -sdk macosx10.15.6 clang++"
CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
CXXFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -fobjc-arc -std=c++11 -stdlib=libc++ -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE"
COPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CXXOPTIMFLAGS="-O2 -fwrapv -DNDEBUG"
CDEBUGFLAGS="-g"
CXXDEBUGFLAGS="-g"
LD="/usr/bin/xcrun -sdk macosx10.15.6 clang"
LDXX="/usr/bin/xcrun -sdk macosx10.15.6 clang++"
LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.9 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map" -L"/Applications/MATLAB_R2017a.app/bin/maci64" -lmx -lmex -lmat -lc++ -Wl,-exported_symbols_list,"/Applications/MATLAB_R2017a.app/extern/lib/maci64/mexFunction.map""
LDDEBUGFLAGS="-g"
DEVELOPER_DIR_CHECK :
XCODE_DIR : /Applications/Xcode.app/Contents/Developer
XCRUN_DIR : /usr/bin
XCODE_AGREED_VERSION : 11.0
ISYSROOT : /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
SDKVER : 10.15.6
MATLABROOT : /Applications/MATLAB_R2017a.app
ARCH : maci64
SRC : /Users/stlee/Dropbox/SharedFolders/SeongtaekDocs/Manuscripts/ASL-FAIR/Data/FAIR-EPIv2-injured-AllinOne/SCIDTI258_1dpi_test/vectors_nlmeans_single.c;/Applications/MATLAB_R2017a.app/extern/version/c_mexapi_version.c
OBJ : /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.o;/var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/c_mexapi_version.o
OBJS : /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.o /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/c_mexapi_version.o
SRCROOT : /Users/stlee/Dropbox/SharedFolders/SeongtaekDocs/Manuscripts/ASL-FAIR/Data/FAIR-EPIv2-injured-AllinOne/SCIDTI258_1dpi_test/vectors_nlmeans_single
DEF : /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.def
EXP : vectors_nlmeans_single.exp
LIB : vectors_nlmeans_single.lib
EXE : vectors_nlmeans_single.mexmaci64
ILK : vectors_nlmeans_single.ilk
MANIFEST : vectors_nlmeans_single.mexmaci64.manifest
TEMPNAME : vectors_nlmeans_single
EXEDIR :
EXENAME : vectors_nlmeans_single
OPTIM : -O2 -fwrapv -DNDEBUG
LINKOPTIM : -O
CMDLINE100_0 : /usr/bin/xcrun -sdk macosx10.15.6 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017a.app/extern/include" -I"/Applications/MATLAB_R2017a.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -O2 -fwrapv -DNDEBUG /Users/stlee/Dropbox/SharedFolders/SeongtaekDocs/Manuscripts/ASL-FAIR/Data/FAIR-EPIv2-injured-AllinOne/SCIDTI258_1dpi_test/vectors_nlmeans_single.c -o /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.o
CMDLINE100_1 : /usr/bin/xcrun -sdk macosx10.15.6 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017a.app/extern/include" -I"/Applications/MATLAB_R2017a.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -O2 -fwrapv -DNDEBUG /Applications/MATLAB_R2017a.app/extern/version/c_mexapi_version.c -o /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/c_mexapi_version.o
-------------------------------------------------------------------
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.15.6 clang -c -DTARGET_API_VERSION=700 -DUSE_MEX_CMD -DMATLAB_MEX_FILE -I"/Applications/MATLAB_R2017a.app/extern/include" -I"/Applications/MATLAB_R2017a.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.9 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -O2 -fwrapv -DNDEBUG /Users/stlee/Dropbox/SharedFolders/SeongtaekDocs/Manuscripts/ASL-FAIR/Data/FAIR-EPIv2-injured-AllinOne/SCIDTI258_1dpi_test/vectors_nlmeans_single.c -o /var/folders/30/t_777qwx27zd6z5vdr3hls_80000gn/T/mex_2170662200551954_54357/vectors_nlmeans_single.o
Error using mex
xcodebuild: error: SDK "macosx10.15.6" cannot be located.
xcrun: error: sh -c '/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk macosx10.15.6 -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
Does anyone please teach me how to resolve this?
The installed version of iOS is macOS Catalina ver 10.15.6, and Xcode ver 12.0.1.
Thanks in advance.
  4 件のコメント
Joseph Bellevue
Joseph Bellevue 2020 年 10 月 12 日
I am having a similar error. Did you get this resolved by chance? If so could you tell me how you fixed it?
Jason
Jason 2020 年 10 月 13 日
Unfortunately, I haven't solved this error yet. Still don't know how to fix it ugh.

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

回答 (2 件)

Christoph
Christoph 2020 年 10 月 17 日
編集済み: Walter Roberson 2020 年 10 月 17 日
Dear all,
I had the same problem and propose the following soltuion:
$xcrun -sdk macosx --show-sdk-version
10.15.6
In
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
you see that a version with the number 10.15 is installed.
I usually changed the mexopts file in the home directory ~/.matlab/R2017b/ but this does not work. The reason is that the SDKVER Variable has the version number 10.15.6.
IF you do not want to change SETVER globally I can provide the follwing workaround (for the C-Compiler).
Copy from
/Applications/MATLAB_R2017b.app/bin/maci64/mexopts/clang_maci64.xml
to your home directory
~/.matlab/R2017b
in <var I changed
CC="$XCRUN_DIR/xcrun -sdk macosx10.15 clang"
CXX="$XCRUN_DIR/xcrun -sdk macosx10.15 clang++"
start Matlab und run
mex -f ~/.matlab/R2017b/clang_maci64.xml *.c
Good luck!
Cheeers
Christoph
  3 件のコメント
William Ruppenthal
William Ruppenthal 2020 年 10 月 21 日
I couldn't get Matlab to read that local options file after creating it, and couldn't find anything easily online about making sure it read the local options, but when I made the global change it worked!
Yaelan Jung
Yaelan Jung 2020 年 11 月 9 日
When I ran the last step (mex -f ~...), there is an error saying 'not enough input arguments', which is weird because I'm giving the file name as input. Would you have any ideas why there's an error? Thank you so much!

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


Srinivas Gorur Shandilya
Srinivas Gorur Shandilya 2020 年 11 月 17 日
I have written a tool to automatically fix this from within MATLAB. Find it here:
https://github.com/sg-s/matlab-catalina-compiler-fix

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by