Matlab 2012a Mex 在 Mountain Lion 上使用 Xcode 4.5

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12643236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:41:09  来源:igfitidea点击:

Matlab 2012a Mex to work with Xcode 4.5 on Mountain Lion

xcodematlabosx-mountain-lionmex

提问by user1706730

I have Mountain Lion installed with Xcode 4.5 and Matlab 2012a. I installed and ran the patch supplied on the MathWorks website however I still received the following error:

我安装了 Xcode 4.5 和 Matlab 2012a 的 Mountain Lion。我安装并运行了 MathWorks 网站上提供的补丁,但仍然收到以下错误:

/Applications/MATLAB_R2012a.app/bin/mex: line 305: llvm-gcc-4.2: command not found
/Applications/MATLAB_R2012a.app/bin/mex: line 1326: llvm-gcc-4.2: command not found

mex: compile of ' "hello.c"' failed.
Error using mex (line 206)

Is there a known solution for that ?

有没有已知的解决方案?

Solution: Open Xcode --> Preferences --> Downloads --> Install "Command Line Tools"

The MathWorks patch is still needed. Resolved issue for me.

解决方案:打开Xcode-->首选项-->下载-->安装“命令行工具”

仍然需要 MathWorks 补丁。为我解决了问题。

回答by Hadi Ravanbakhsh

You don't need to install XCode. I installed Command Line Tools and then edit the file "/Applications/MATLAB_R2012a.app/bin/mexopts.sh" and

您不需要安装 XCode。我安装了命令行工具,然后编辑文件“/Applications/MATLAB_R2012a.app/bin/mexopts.sh”和

changed CC from gcc-4.2 to llvm-gcc-4.2

将 CC 从 gcc-4.2 更改为 llvm-gcc-4.2

changed CXX from gcc-4.2 to llvm-g++-4.2

将 CXX 从 gcc-4.2 更改为 llvm-g++-4.2

set SDKROOT to '/'

将 SDKROOT 设置为“/”

It's done. Now, you just need to run "mex -setup" in MATLAB

完成。现在,您只需要在 MATLAB 中运行“mex -setup”

Worked for me (Mac OSX 10.8.2, Command Line Tools - October 2012, MATLAB 2012a)

对我来说有效(Mac OSX 10.8.2,命令行工具 - 2012 年 10 月,MATLAB 2012a)