我尝试使用Xcode 5在我的MacBook Pro OS X 10.9上安装nfft package。 当我测试nfft包时,我必须使用以下命令编译.c文件:
fftw3Path='/Users/boyer/Documents/MATLAB/fftw-3.3.4/';
nfft3Path='/Users/boyer/Documents/MATLAB/nfft-3.2.3/';
Ipath=[' -I' nfft3Path 'include ' ' -I' nfft3Path 'applications/fastsum ' '-I' fftw3Path 'api ' '-I' nfft3Path 'matlab ' ];
Lpath=['-L' nfft3Path ' ' '-L' nfft3Path 'applications/fastsum' ' ' '-L' fftw3Path 'api' ];
command=sprintf(['mex -v -Dchar16_t=uint16_t ' Lpath ' ' Ipath ' -lfftw3 -lnfft3 nfftmex.c']);
eval(command)
以下是我得到的答案:
Building with 'Xcode with Clang'.
/usr/bin/xcrun -sdk macosx10.8 clang -c -Dchar16_t=uint16_t -DMX_COMPAT_32 -DMATLAB_MEX_FILE -I/Users/boyer/Documents/MATLAB/nfft-3.2.3/include -I/Users/boyer/Documents/MATLAB/nfft-3.2.3/applications/fastsum -I/Users/boyer/Documents/MATLAB/fftw-3.3.4/api -I/Users/boyer/Documents/MATLAB/nfft-3.2.3/matlab -I"/Applications/MATLAB_R2014a.app/extern/include" -I"/Applications/MATLAB_R2014a.app/simulink/include" -fno-common -arch x86_64 -mmacosx-version-min=10.8 -fexceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -O2 -DNDEBUG /Users/boyer/Documents/MATLAB/nfft-3.2.3/matlab/nfft/nfftmex.c -o /var/folders/_0/63lwd1z17j94w_7wgkrw3x700000gn/T//mex_2747778005296_34460/nfftmex.o
/usr/bin/xcrun -sdk macosx10.8 clang -Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=10.8 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -bundle -Wl,-exported_symbols_list,"/Applications/MATLAB_R2014a.app/extern/lib/maci64/mexFunction.map" /var/folders/_0/63lwd1z17j94w_7wgkrw3x700000gn/T//mex_2747778005296_34460/nfftmex.o -O -Wl,-exported_symbols_list,"/Applications/MATLAB_R2014a.app/extern/lib/maci64/mexFunction.map" -lfftw3 -lnfft3 -L/Users/boyer/Documents/MATLAB/nfft-3.2.3/ -L/Users/boyer/Documents/MATLAB/nfft-3.2.3/applications/fastsum -L/Users/boyer/Documents/MATLAB/fftw-3.3.4/api -L"/Applications/MATLAB_R2014a.app/bin/maci64" -lmx -lmex -lmat -lstdc++ -o nfftmex.mexmaci64
Error using mex
Undefined symbols for architecture x86_64:
"_nfft_mex_get_int", referenced from:
_mexFunction in nfftmex.o
"_nfft_mex_install_mem_hooks", referenced from:
_mexFunction in nfftmex.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
使用MatlabR2011b,我更改了mexopts.sh文件,如下所示:
;; maci64) #---------------------------------------------------------------------------- #PATCH: MacOSX10.9 CC='llvm-gcc' CXX='llvm-g++' SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/'
MACOSX_DEPLOYMENT_TARGET='10.9'
ARCHS='x86_64'
# StorageVersion: 1.0
# CkeyName: GNU C
# CkeyManufacturer: GNU
# CkeyLanguage: C
# CkeyVersion:
CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
#CFLAGS='-ansi -D_GNU_SOURCE'
CFLAGS="$CFLAGS -std=c99"
CFLAGS="$CFLAGS -fexceptions"
CLIBS="$MLIBS"
COPTIMFLAGS='-O2 -DNDEBUG'
CDEBUGFLAGS='-g'
#
CLIBS="$CLIBS -lstdc++"
# C++keyName: GNU C++
# C++keyManufacturer: GNU
# C++keyLanguage: C++
# C++keyVersion:
CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
CXXFLAGS='-ansi -D_GNU_SOURCE'
CXXLIBS="$MLIBS -lstdc++"
CXXOPTIMFLAGS='-O2 -DNDEBUG'
CXXDEBUGFLAGS='-g'
我还尝试通过-std = libstdc ++更改库-lstdc ++。什么都解决了这个问题。
然后我使用了MatlabR2014a,我也有同样的错误(但在这个版本中,我们无法修改mexopts.sh,它似乎已被mex_C_maci64.xml取代)。
我想也许我会安装另一个太糟糕的c编译器,因为至少MatlabR2014a应该与Xcode5兼容。
如果您有任何建议,请提前感谢。
答案 0 :(得分:0)
我讨厌在OSX上安装软件时撞到砖墙,所以我使用homebrew
用于ImageMagick,GNU coreutils,gawk,sed,ffmpeg,gnuplot,GNU parallel,REDIS,opencv,jhead, p7zip等。
nfft
似乎有一个公式,所以我怀疑您需要做的就是安装homebrew
,转到their website并按照简单的单行指令操作。然后,您可以tap
进入存储库的科学分支并安装nfft
,如下所示:
brew tap homebrew/science
brew install nfft
你完成了!如果有任何问题,请运行
brew doctor
答案 1 :(得分:0)
感谢您的帮助和有用的建议。现在,它似乎通过在安装nfft包时应用以下命令(make和make install之前):
./configure --with-fftw3='/usr/local' --with-fftw3-libdir='/usr/local/lib' --with-fftw3-includedir='/usr/local/include' --with-matlab='/Applications/MATLAB_R2014a.app' --with-matlab-fftw3-libdir='/usr/local/lib'
另一个评论:即使OS X的版本是10.9,matlab也会选择10.8sdk。为避免这种情况,您可以编辑文件mex_C_maci64.xml,并反转2行代码:
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk" />
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" />
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" />
<cmdReturns name="find $$ -name MacOSX10.7.sdk" />
<cmdReturns name="find $$ -name MacOSX10.9.sdk" />
<cmdReturns name="find $$ -name MacOSX10.8.sdk" />
而不是
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk" />
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk" />
<dirExists name="$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" />
<cmdReturns name="find $$ -name MacOSX10.7.sdk" />
<cmdReturns name="find $$ -name MacOSX10.8.sdk" />
<cmdReturns name="find $$ -name MacOSX10.9.sdk" />
端
希望它可以帮助别人。再次感谢您的回答。