2013-02-15 107 views
3

用Xcode 4.6在Mac OS X 10.8.2下编译hello.c,我发出了推荐使用xcrun gcc cannot find header files的xcrun命令,但仍然收到错误,头文件stdio .h无法找到。xcrun铿锵--sysroot找不到stdio.h

$ xcrun clang --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/ -o hello hello.c 
hello.c:2:10: fatal error: 'stdio.h' file not found 
#include <stdio.h> 
    ^
1 error generated. 
$ cat hello.c 
/* C program, Hello World */ 
#include <stdio.h> 
int main() 
{ 
    printf("Hello World \n"); 
} 

回答

1

它应该工作: xcrun铛-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/

0

我改变我没有指定该项目的Build Settings,因为Base SDK未指定。一旦我将其更改为OS X 10.7(或者您使用的任何应用都可以),我就能够成功编译所有内容,而无需更改其他构建配置。