Installing GCC on Mac
来源:互联网 发布:sql sqlserver一样吗 编辑:程序博客网 时间:2024/06/05 19:21
Suppose you want to use the latest and greatest version of GCC on the Mac because you want to use features inC++11 that are not yet available in XCode. There are probably a few ways to do this, but one way is viaMacPorts which provides precompiled binaries for tons of packages.
You can follow the following steps to install GCC 4.7 via MacPorts. Others versions (including GCC 4.8) follow a pretty similar procedure.
- Browse to the MacPorts website. Download the DMG image for your operating system
- Install the package
- Open up a terminal Applications > Utilities > Terminal
- Make sure that you have the latest version by running the self update via the terminal command
sudo port selfupdate
- Install GCC via the terminal command
sudo port install gcc47
Now sit back and wait while MacPorts does its thing. One MacPorts is done, the next thing is to compile a simple program. Running gcc or g++ at the command line invokes the compiler installed with XCode. The new executables are installed to
/opt/local/bin/gcc-mp-4.7
and
/opt/local/bin/g++-mp-4.7
- Depending on your build environment, you may want to access GCC by running gcc or g++ at the command line. Because the MacPorts are installed to another location, you either need to either specify the full path, or set the compiler to use on your system. For the second option, you can use MacPorts to select the default compiler. First, identify which versions are installed on your system.
port select --list gcc
In my case, this returns
Available versions for gcc: gcc42 llvm-gcc42 mp-gcc47 none (active)
To select GCC 4.7, run the command
sudo port select --set gcc mp-gcc47Password:Selecting 'mp-gcc47' for 'gcc' succeeded. 'mp-gcc47' is now active.
在MAC下切换GCC编译器的办法(MacPorts)
这里的办法是通过port命令选项实现的,所以需要先安装MacPorts,具体的安装步骤就不多说了,切换不同版本gcc的命令如下:
执行:
$ sudo port select --list gcc
显示:
Password:
Available versions for gcc:
gcc42
llvm-gcc42
mp-gcc45 (active)
none
选择llvm-gcc42作为编译器,执行:
$ sudo port select --set gcc llvm-gcc42
显示:
Selecting 'llvm-gcc42' for 'gcc' succeeded. 'llvm-gcc42' is now active.
以前版本的MacPorts是通过 gcc_select 来切换gcc版本的,不过今天我执行无效,一查才知道官网投票取消了 gcc_select,用参数 select 来实现了。
- Installing GCC on Mac
- Installing scrapy on mac
- Installing MongoDB on a Mac
- Tutorial – Installing gcc compiler on iPhone
- installing mac os on esxi 5.0
- Installing boost on Mac OS X
- Installing wget On Your Mac For Terminal
- Installing libevent on MAC OSX 10.6
- INSTALLING OPERATING SYSTEM IMAGES ON MAC OS
- Installing Wine on Mac OS X
- Installing ADB on MAC OS X
- Installing TensorFlow on Mac OS X
- Installing GCC
- gcc installing
- Installing GCC
- Installing JDeveloper on Mac OS X Lion (10.7)
- Installing PostGIS 0.8.0 on Mac OS 10.3.2
- Installing Eclipse on Mac OS X 64 bit
- Make Tomcat Ignore Servlet in WEB-INF/LIB
- RBM
- 【php+zendframework】调试
- 【Discuz】Discuz的下载、配置与Helloworld
- java 分页类(工具类)
- Installing GCC on Mac
- 安装GenyMotion时出现的错误解决
- 欢迎使用CSDN-markdown编辑器
- centos安装php php-fpm 以及 配置nginx
- 使用Activity类中的公共方法在UI线程中进行耗时操作
- poj3087 Shuffle'm Up
- 中文乱码
- HDU 1327 Knight Moves
- List集合