macos 无法在 OS X 终端中使用 GCC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1810327/
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
Can't use GCC in OS X Terminal
提问by Chris Kempson
I have installed the developer tools. I can compile code via Xcode and according to the docs /usr/bin/gcc & /usr/bin/cc should point to /usr/bin/gcc-4.0. Neither the symlinks or gcc-4.0 exist on my system (Snow Leopard). All I wish to do is compile some C on the terminal! I'm amazed by how complicated this task is. The command GCC is unsurprisingly returning "gcc: command not found".
我已经安装了开发者工具。我可以通过 Xcode 编译代码,根据文档 /usr/bin/gcc & /usr/bin/cc 应该指向 /usr/bin/gcc-4.0。我的系统(雪豹)上既不存在符号链接,也不存在 gcc-4.0。我想做的就是在终端上编译一些 C!我对这项任务的复杂程度感到惊讶。不出所料,命令 GCC 返回“gcc: command not found”。
Can anyone shed some light on this?
任何人都可以对此有所了解吗?
采纳答案by Alnitak
Did you install the latest Xcode after installing Snow Leopard, or is this the version of Xcode from a previous OS installation?
您在安装 Snow Leopard 后是否安装了最新的 Xcode,或者这是之前操作系统安装的 Xcode 版本?
On my system with a clean Snow Leopard install the default compiler (and the one symlinked from cc and gcc) is gcc-4.2
在我的系统上安装了一个干净的 Snow Leopard 的默认编译器(以及来自 cc 和 gcc 的符号链接)是 gcc-4.2
I do have gcc-4.0 too, although it's not the default.
我也有 gcc-4.0,虽然它不是默认的。
回答by Tim Keating
No! Reinstalling is the wrong answer!
不!重新安装是错误的答案!
Newer versions of XCode require you to install the command-line versions of the tools separately. In XCode, go to Preferences | Downloads, check the Components tab, and install them from there:
较新版本的 XCode 要求您单独安装这些工具的命令行版本。在 XCode 中,转到首选项 | 下载,检查组件选项卡,然后从那里安装它们:
回答by Patrick
Command line tools are no longer included with the latest XCode (even as an add on). Now you can download them here:
命令行工具不再包含在最新的 XCode 中(即使作为附加组件)。现在你可以在这里下载它们:
回答by ennuikiller
These binaries should be there after installing xcode. Check your path settings, and if you still don't have these reinstall xcode
安装 xcode 后,这些二进制文件应该就在那里。检查您的路径设置,如果您仍然没有这些,请重新安装 xcode