2013-02-15 109 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(或者您使用的任何應用都可以),我就能夠成功編譯所有內容,而無需更改其他構建配置。