MATLAB MEX找不到带有XCode 4.3的标准库(Mac) [英] MATLAB MEX can't find standard library with XCode 4.3 (Mac)

查看:149
本文介绍了MATLAB MEX找不到带有XCode 4.3的标准库(Mac)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在Mac(运行OSX 10.7.3,Lion)上使用从C代码(使用XCode 4.3)编译的MATLAB(R2012a)MEX文件.我已经安装了 XCode补丁所提供的MATLAB在XCode 4.2+下使用新的llvm-gcc编译器,但是尝试使用mex timestwo.c编译示例文件时仍然出现以下错误:

I am getting started with using MEX files for MATLAB (R2012a) compiled from C code (using XCode 4.3) on my Mac (running OSX 10.7.3, Lion). I have already installed the MATLAB provided XCode patch which configures MATLAB to use the new llvm-gcc compiler under XCode 4.2+, but I am still getting the following error attempting to compile the example file using mex timestwo.c:

/Applications/MATLAB_R2012a.app/extern/include/matrix.h:852:20: error: stdlib.h: No such file or directory
In file included from timestwo.c:1:
/Applications/MATLAB_R2012a.app/extern/include/mex.h:161:19: error: stdio.h: No such file or directory

然后编译中断

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

Error using mex (line 206)
Unable to complete successfully.

很显然,编译器找不到标准库头目录,但是要成功编译我需要更改什么?

Clearly, the compiler can't find the standard library header directory, but what do I need to change to successfully compile?

推荐答案

啊,找到了!

MATLAB提供的模板使用/Developer/...作为SDK的位置,但这在XCode4.3下更改为可以在XCode.app下使用.为了解决问题,我必须编辑我的~/.matlab/R2012a/mexopts.sh文件以将SDKROOT目录设置为新位置.

The MATLAB provided template uses /Developer/... for the SDK location, but this changed under XCode4.3 to live under the XCode.app. To fix things, I had to edit my ~/.matlab/R2012a/mexopts.sh file to set the SDKROOT directory to the new location.

为此,请在mexopts.sh文件中搜索SDKROOT并将其更改为:

To do this, search for SDKROOT in the mexopts.sh file and change it to read:

SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/'

注意,我选择了Lion上的10.7 sdk b/c.如果您在雪豹上,请使用10.6

Note, I chose the 10.7 sdk b/c I am on Lion. Use 10.6 if you are on Snow Leopard

这篇关于MATLAB MEX找不到带有XCode 4.3的标准库(Mac)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆