OSX 10.8、Xcode 4.4 Make 和 gcc 从环境中消失
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11654702/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
OSX 10.8, Xcode 4.4 Make and gcc gone from environment
提问by Kris
I just upgraded to Mountain Lion OSX 10.8 and along with that I foolishly upgraded to Xcode 4.4.
我刚刚升级到 Mountain Lion OSX 10.8,同时我愚蠢地升级到 Xcode 4.4。
However, after this upgrade "make" is gone and things like gcc -v also do not work.
然而,在这次升级之后,“make”消失了,像 gcc -v 这样的东西也不起作用。
This is a big thing since I am writing my phD and I rely on make to compile my LaTeX docs...
这是一件大事,因为我正在写我的博士学位并且我依靠 make 来编译我的 LaTeX 文档......
Downloading the "command line tools"
下载“命令行工具”
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
Is apparently not allowed for non-paying dev accounts.
显然不允许非付费开发帐户。
What kind of foolishness is this?
这是一种什么样的愚蠢?
回答by Mark Wang
They're not gone, they've just been relocated to inside Xcode's app bundle. This is actually nicer as it allows side by side installs of different XCode/SDK versions.
它们并没有消失,它们只是被重新定位到 Xcode 的应用程序包中。这实际上更好,因为它允许并行安装不同的 XCode/SDK 版本。
You can find them at: /Applications/Xcode.app/Contents/Developer/usr/bin
您可以在以下位置找到它们:/Applications/Xcode.app/Contents/Developer/usr/bin
Also check out the xcode-select tool to allow you to choose the current active toolchain path.
还可以查看 xcode-select 工具以允许您选择当前活动的工具链路径。
回答by lead_brogrammer
I did the same thing as you this morning. To fix it, I just added the following to my ~/.bash_profile:
我今天早上和你做了同样的事情。为了修复它,我只是在 ~/.bash_profile 中添加了以下内容:
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
回答by Kris
Interestingly,
有趣的是,
The "Downloads" interface inside Xcode 4.4 seems to point to the following location for downloading the "Command line tools":
Xcode 4.4 中的“下载”界面似乎指向以下用于下载“命令行工具”的位置:
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
http://adcdownload.apple.com/Developer_Tools/xcode_4.4_gm_seed/cltools10_8gmseed6938077a.dmg
Judging by the "gm" reference in that URL I think this is an error. Without a paying dev account you cannot download this...
根据该 URL 中的“gm”引用判断,我认为这是一个错误。如果没有付费开发帐户,您将无法下载此...
回答by Greg Coats
I issued the export PATH command, and then tried to compile hello.c, but compilation fails because it does not find the file stdio.h. So, I changed the include statement to specify the full path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/stdio.h, but then compilation fails because it does not find 3 other .h files.
我发出export PATH命令,然后尝试编译hello.c,但是编译失败,因为没有找到stdio.h文件。因此,我更改了包含语句以指定完整路径 /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
回答by weisen
Old thread, but I was just looking for this myself in Xcode 4.6:
旧线程,但我只是在 Xcode 4.6 中自己寻找这个:
- Install Xcode
- Go to Preferences->Downloads->Components and there will be an "Install" button next to "Command Line Tools"
- 安装 Xcode
- 转到首选项-> 下载-> 组件,“命令行工具”旁边将有一个“安装”按钮