我发出了 export 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