我想在OSX山獅編譯一個c文件。在Xcode 4.4中,首選項 - >下載我可以安裝命令行工具來做到這一點。然而在該窗格其通知我,我可以改用xcrun:xcrun gcc找不到頭文件
Before installing, note that from within Terminal you can use the XCRUN tool to launch compilers and other tools embedded within the Xcode application. Use the XCODE-SELECT tool to define which version of Xcode is active. Type "man xcrun" from within Terminal to find out more.
我很樂意這樣做的,但我無法得到它找到stdio.h中。
$ xcrun gcc hello.c
hello.c:1:19: error: stdio.h: No such file or directory
我絕對有這個文件我的系統上後,通過標準的應用程序商店安裝的Xcode: /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10 .8.sdk/usr/include目錄/文件stdio.h
我試圖指定SDK,但得到了同樣的錯誤:
$ xcrun -sdk /Applications/Xcode.app/Contents/Developer//Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk gcc hello.c
一些谷歌搜索導致我嘗試上述命令之前運行的Xcode選,但沒有運氣。無論如何,我只有一個版本的Xcode。
$ sudo xcode-select -switch /Applications/Xcode.app
我怎樣才能得到它找到的頭?
最終我放棄了並安裝了命令行工具,但很高興知道如何使用內置的Xcode工具來完成它。
注:這裏是我試圖編譯文件:
#include <stdio.h>
int main() {
printf("hello world!\n");
return 0;
}
是的,這是一個非常有用的點,即使它不是這個問題的答案。 – 2012-09-06 02:23:10