本文翻译自:How to use/install gcc on Mac OS X 10.8 / Xcode 4.4
I have install Mountain Lion (Mac OS X 10.8) and now gcc doesn't seem to be available anymore. 我已安装Mountain Lion(Mac OS X 10.8),现在gcc似乎不再可用了。 I've also installed Xcode 4.4 so there is no more /Developer directory. 我还安装了Xcode 4.4,因此没有更多/ Developer目录。
I need gcc both for mac ports and for ruby gems (that have native extensions). 我需要gcc用于mac端口和ruby gems(具有本机扩展)。
Does Xcode 4.4 include gcc or is there a way to install gcc? Xcode 4.4是否包含gcc或有没有办法安装gcc?
#1楼
参考:https://stackoom.com/question/dFG0/如何在Mac-OS-X-Xcode-上使用-安装gcc
#2楼
For users who can download from Apple a build of Xcode, but not the command line tools 对于可以从Apple下载Xcode的用户而不是命令行工具的用户
An accepted answer to a comparable question suggests kennethreitz / osx-gcc-installer . 对类似问题的接受答案表明kennethreitz / osx-gcc-installer 。 In that 'OSX GCC Installer' area, the first of two options is pre-built binaries — for Snow Leopard and for Lion, but not for Mountain Lion. 在那个'OSX GCC安装程序'区域,两个选项中的第一个是预构建的二进制文件 - 用于Snow Leopard和Lion,但不适用于Mountain Lion。 Considering what's included, I should not recommend using that project's GCC-10.7-v2.pkg after installing version 4.4 of Xcode on any build of 10.8. 考虑到包含的内容,我不建议在任何版本的10.8上安装4.4版本的Xcode 之后使用该项目的GCC-10.7-v2.pkg。
The more relevant option is build your own , with reference to Apple open source for Developer Tools. 更相关的选项是构建自己的选项,参考Apple Developer for Developer Tools。
Sources for GCC, compatibility with 10.8 GCC的来源,与10.8的兼容性
Apple Open Source for the most recently published Developer Tools 4.3 is without GCC. 最近发布的Developer Tools 4.3的 Apple Open Source没有GCC。 The source for GCC in the 4.1 area may be too old for use with 10.8. 4.1区域中GCC的来源可能太旧而无法与10.8一起使用。
GCC home page for the most recent release. 最新发布的GCC主页 。
Build status for GCC 4.7 links to results for x86_64-apple-darwin10.8.0 … GCC 4.7的构建状态链接到x86_64-apple-darwin10.8.0的结果 ...
#3楼
I found that after upgrading from Lion my install was failing because it was looking for GCC in /usr/bin/gcc-4.2. 我发现从Lion升级后我的安装失败了,因为它在/usr/bin/gcc-4.2中寻找GCC。 Now the default installation path is /usr/bin/gcc. 现在默认的安装路径是/ usr / bin / gcc。
My error looked like this: 我的错误看起来像这样:
make: /usr/bin/gcc-4.2: No such file or directory
A symlink will sort out the issue: 符号链接将解决问题:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
#4楼
Apple provides an .mpkg
installer for the Command Line Tools (CLT), but they don't normally expose the link. Apple为命令行工具(CLT)提供.mpkg
安装程序,但它们通常不会公开链接。 It includes GCC. 它包括GCC。 You can install it without downloading/installing XCode. 您可以在不下载/安装XCode的情况下安装它。
Download Command Line Tools w/ GCC here. 在此处下载带GCC的命令行工具。
#5楼
pre-1.9.3 Ruby on Mountain Lion 1.9.3之前Ruby on Mountain Lion
Pre-requisites 先决条件
Xcode 4.4,
Xcode Command Line Tools
Homebrew
XQuartz 2.7.2 or later.
rbenv/ruby-build or RVM.
Install GCC 安装GCC
Note, the Xcode Command Line Tools do not include GCC, they include LLVM-GCC. 注意,Xcode命令行工具不包括GCC,它们包括LLVM-GCC。 Same-same, but different. 相识又有差别。
$ brew tap homebrew/dupes
$ brew install apple-gcc42
Add the following to your ~/.profile or equivalent: 将以下内容添加到〜/ .profile或等效内容中:
export CC=/usr/local/bin/gcc-4.2
And reload your shell before attempting the install commands below. 并在尝试下面的安装命令之前重新加载shell。
Install RVM 安装RVM
CFLAGS="-I/opt/X11/include" rvm reinstall ree
Install Ruby 安装Ruby
Prefix the install command with CFLAGS="-I/opt/X11/include"
Then to set your new ruby as default: 然后将新ruby设置为默认值:
user$ rvm use 1.9.2 --default
Then check your ruby version: 然后检查你的ruby版本:
user$ ruby -v
#6楼
You can download the installer(.pkg file) lattest version of GCC for Mountain Lion from this site. 您可以从此站点下载Mountain Lion的安装程序(.pkg文件)lattest版本。 You simpy need to download and install it. 您需要下载并安装它。
https://github.com/kennethreitz/osx-gcc-installer/downloads https://github.com/kennethreitz/osx-gcc-installer/downloads