MATLAB MEX can't find standard library with XCode 4.3 (Mac)

微笑、不失礼 提交于 2019-12-01 05:26:55

Ah, found it!

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.

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/'

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

fgar

I am running Mac Mountain Lion and Matlab R2012b, and the following solution worked for me: Matlab 2012a Mex to work with Xcode 4.5 on Mountain Lion

To be precise, I was getting the following errors:

error: stdio.h: No such file or directory

error: stdlib.h: No such file or directory

error: math.h: No such file or directory

So what I did to solve this issue:

I installed Xcode with Command Line Tools, and then edited the file "/Applications/MATLAB_R2012b.app/bin/mexopts.sh" by:

changing CC from gcc-4.2 to llvm-gcc-4.2

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

setting SDKROOT to '/'

Then I ran "mex -setup" in MATLAB, chose number 1, and chose y to overwrite the old /Users/insertyournamehere/.matlab/R2012b/mexopts.sh

That solved it :)

You will find valuable information here: http://www.mathworks.fr/support/solutions/en/data/1-FR6LXJ/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!