OSX 上的 gcc 在哪里?我已经安装了 Xcode
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2685887/
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
Where is gcc on OSX? I have installed Xcode already
提问by OscarRyz
I have installed Xcode from the Tool cd, I thought that would let me use gcc from the command line but I can't find it.
我已经从 Tool cd 安装了 Xcode,我认为这可以让我从命令行使用 gcc,但我找不到它。
What am I missing
我错过了什么
EDIT
编辑
When I wrote I can't find itI meant "I look for it using which gcc
"
当我写我找不到它时,我的意思是“我用它寻找它which gcc
”
If gcc
would have been in the PATH
in first place, which
would have find it.
如果gcc
本来就PATH
在第一位,which
就会找到它。
Since gcc
is not in the PATH
( that's what brought me here in first place ) which
won't find it!
由于gcc
不在PATH
(这就是首先将我带到这里的原因)which
不会找到它!
I think that was obvious but I'm making the note here because it wasn't
我认为这很明显,但我在这里做笔记是因为它不是
采纳答案by Stephen Canon
You didn't check the box that says "UNIX Development Support"[1] (or possibly you unchecked it; I can't remember if it's on by default or not) when you did the install, so it didn't install the necessary symlinks and drivers in /usr/bin/
.
您在安装时没有选中“UNIX 开发支持”[1] 框(或者您可能未选中它;我不记得默认情况下它是否打开),因此它没有安装中必要的符号链接和驱动程序/usr/bin/
。
Reinstall, and make sure to read the descriptions of the configuration options and select the ones that you need.
重新安装,并确保阅读配置选项的说明并选择您需要的选项。
1: "Optional content to allow command-line development from the boot volume. Installs a duplicate of the GCC compiler and command line tools blah blah blah..."
1:“允许从引导卷进行命令行开发的可选内容。安装 GCC 编译器和命令行工具的副本等等……”
回答by Bob Swerdlow
As of version 4.3.1, XCode is now an application and the command line tools are now available through the Preferences (this is documented in the App Store for XCode under 'What's New in Version 4.3.1' if you click 'More...'). After installing XCode, open it, open the Preferences and click on the Download tab. Click on 'install' for the 'Command Line Tools' and then sign in with your computer's password. The code will then be downloaded and installed.
从 4.3.1 版开始,XCode 现在是一个应用程序,现在可以通过首选项使用命令行工具(如果您单击“更多.. .')。安装 XCode 后,打开它,打开首选项并单击下载选项卡。单击“命令行工具”的“安装”,然后使用您的计算机密码登录。然后将下载并安装代码。
回答by diciu
Something went wrong with your install.
您的安装出现问题。
gcc is installed under /usr/bin with a symlink to gcc-4.2:
gcc 安装在 /usr/bin 下,带有指向 gcc-4.2 的符号链接:
cd diciu$ pkgutil --file-info /usr/bin/gcc-4.2
volume: /
path: /usr/bin/gcc-4.2
pkgid: com.apple.pkg.gcc4.2Leo
pkg-version: 4.2.0.9000000000.1.1249367152
[..]
pkgid: com.apple.pkg.Xcode3.2.1Update
pkg-version: 1.0.1.1249367152
[..]
pkgid: com.apple.pkg.Xcode3.2.1UpdateUNIXDevSupport
pkg-version: 1.0.1.1249367152
[..]
回答by maerics
On my Mac $ which gcc
displays /usr/bin/gcc
.
在我的 Mac 上$ which gcc
显示/usr/bin/gcc
.
回答by Jeremy Rowe
Xcode 4.3+ you need to install 'Command Line Tools for Xcode' found here: https://developer.apple.com/downloads
Xcode 4.3+ 你需要安装'Command Line Tools for Xcode' 在这里找到:https: //developer.apple.com/downloads
回答by Brian Postow
Is it possible that rather than not having gcc installed, your $PATH variable is messed up? first check if gcc is in /usr/bin manually. Then echo $PATH...
有没有可能不是没有安装 gcc,而是你的 $PATH 变量搞砸了?首先手动检查 gcc 是否在 /usr/bin 中。然后回显 $PATH...
回答by dawg
The same thing happened to me. It worked for a while and then went away. Reinstall and it will be fixed.
这样的事情我也经历过。它工作了一段时间,然后消失了。重新安装,它将被修复。
You might want to download Xcode from Apple while you are at it. Almost guaranteed to be fresher / more up-to-date since Xcode is rapidly updated. Current Xcode is 3.2.1.10. You need an Apple ID to download, but that also gives you access to the development site. All free... .
您可能想在使用时从 Apple 下载 Xcode。由于 Xcode 快速更新,几乎可以保证更新/更新。当前的 Xcode 是 3.2.1.10。您需要一个 Apple ID 才能下载,但这也使您可以访问开发站点。全部免费....
It is 1/6/2014. Current Xcode is 5.0.1
现在是 2014 年 1 月 6 日。当前的 Xcode 是 5.0.1
It is 2016 -- Current Xcode is 8.0. I think this question should be closed now.
现在是 2016 年——当前的 Xcode 是 8.0。我认为这个问题现在应该结束了。
回答by Elaine
Yes, try to install 'command line tools' by clicking Preferences-Downloads-command line tools.
是的,尝试通过单击首选项-下载-命令行工具来安装“命令行工具”。