当前位置: 首页 > 工具软件 > LightSpeed > 使用案例 >

为mac的matlab安装lightspeed

葛越泽
2023-12-01

Lightspeed Matlab toolbox

lightspeed是Tom Minka为matlab写的加速函数库(一堆.c文件和.m文件),作者在windows下测试,并认为在mac和linux下也能工作

以下是我在OS X EI Capitan(OS 10.11.3),matlab R2013a环境下安装lightspeed遇到的问题和解决方案

>> cd lightspeed/
>> install_lightspeed
Compiling lightspeed 2.7 mex files...
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH

    mex: compile of ' "flops.c"' failed.

这说明SDK版本不匹配,在终端运行

$ xcrun --show-sdk-path

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk

可以直接修改matlab根目录的mexopts.sh文件(先备份,防止不可逆的错误)

>>cd(matlabroot)

>>cd bin

>>edit mexopts.sh

大约128行,把10.6全部换成10.11

>>mex -setup(出现选项,选1,y)

或直接修改~/.matlab/R2013a/mexopts.sh


回到lightspeed目录,重新运行install_lightspeed

/Applications/MATLAB_R2013a.app/extern/include/tmwtypes.h:819:9: error: unknown
      type name 'char16_t'
typedef char16_t CHAR16_T;

修改~/.matlab/R2013a/mexopts.sh,在137行CFLAG中加上-Dchar16_t=UINT16_T

CFLAGS="$CFLAGS  -fexceptions -Dchar16_t=UINT16_T"


再次运行install_lightspeed

clang: error: no such file or directory: 'librandom.dylib'

    mex: link of ' "randomseed.mexmaci64"' failed.

这次应该修改install_lightspeed.m了

>>mex -v -c flops.c

-> xcrun  -sdk macosx10.11  clang -c  -I/Applications/MATLAB_R2013a.app/extern/include -I/Applications/MATLAB_R2013a.app/simulink/include -DMATLAB_MEX_FILE -fno-common -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11  -fexceptions -Dchar16_t=UINT16_T  -DMX_COMPAT_32 -O2 -DNDEBUG  "flops.c"

用上述信息修改install_lightspeed.m第68行开始的信息,比如我的

    options.COMPILER = 'clang';

    options.COMPFLAGS = '-fno-common -no-cpp-precomp -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.11  -fexceptions';


再次运行,成功!!!

lightspeed's matfile utility is not supported for this version of Matlab
Done.
Type "test_lightspeed" to verify the installation.


lightspeed下载链接

http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/

问题解决帖

http://cn.mathworks.com/matlabcentral/answers/103904-can-i-use-xcode-5-as-my-c-or-c-compiler-in-matlab-8-1-r2013a-or-matlab-8-2-r2013b

http://levinboim.blogspot.com/2013/02/quick-note-on-installing-lightspeed.html 


 类似资料: