我頒發的出口PATH命令,然後試圖編譯hello.c的,而是因爲它沒有找到該文件STDIO編譯失敗。H。因此,我更改了include語句以指定完整路徑/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h,但隨後編譯因爲沒有找到3個其他的.h文件而失敗。
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
cat hello.c
#include <stdio.h>
int main()
{
printf("Hello World \n");
}
gcc hello.c -o hello
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
gcc hello.c -o hello
In file included from hello.c:2:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:64:23: error: sys/cdefs.h: No such file or directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:65:26: error: Availability.h: No such file or directory
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h:67:20: error: _types.h: No such file or directory
這是蘋果公司的錯誤;他們似乎對每次Xcode更新都有這個問題。命令行工具不需要付費開發者帳戶。嘗試從Xcode>首選項>下載安裝它們。 – 2012-07-29 01:44:31