什么是GCC
GCC(GNU Compiler Collection)是由自由软件基金会(FSF, Free Software Foundation, Inc)研发的开源编译器集合。
用一句话说,GCC就是除Windows以外的平台上使用最广的编译器。
在非Wndows系统上,我使用GCC来编译STL相关的代码。
在Mac OS X系统中,默认是没有安装GCC的。 如果在终端中输入gcc,则有下面的提示
$ gcc
-bash: gcc: command not found
安装Xcode
安装GCC之前,需要先安装Mac系统的开发工具Xcode。
- 启动Mac App Store
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/start-mac-app-store.png)
- 查找Xcode
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/search-xcode-in-mac-app-store.png)
- 安装Xcode
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/install-xcode-in-mac-app-store.png)
如图,我已经安装了Xcode。
安装GCC
从Lacunchpad中
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/mac-launchpad.png)
启动Xcode
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/start-xcode-from-launchpad.png)
打开Xcode的Preference
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/open-xcode-preference.png)
选择 Downloads下的Components,然后在「Command Line Tools」那一行点击“Install”按钮
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/install-command-line-tools-in-xcode.png)
因为我已经安装过了,所以显示的是「Installed」
测试GCC
安装在Launchpad中选择「终端」,启动后输入
$ gcc
输出如下
i686-apple-darwin11-llvm-gcc-4.2: no input files
如图:
![image](http://stlexamples.com/files/how-to-install-gcc-on-mac-with-xcode/gcc-installed.png)
测试平台:
文档信息
- 版权声明:自由转载-非商用-非衍生-保持署名 | Creative Commons BY-NC-ND 3.0
- 作者:林杰(Lin Jie) http://linjiex.com
- 原文网址:http://stlexamples.com/How-to-install-gcc-on-mac-with-xcode
- 最后修改时间:2012-12-20