Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I install GCC 4.7.2 on OS X 10.8?

I don't care about keeping the Xcode version of "GCC", I just need GCC 4.7.2

share|improve this question
Download gcc 4.7.2. Build it according the instructions. Install it according to the instructions. – David Schwartz Dec 10 '12 at 10:54
up vote 10 down vote accepted


The easiest way is to use MacPorts which provides

gcc47 @4.7.2 (lang) The GNU compiler collection

Install MacPorts and then

sudo port install gcc47

This will install several binaries with the -mp-4.7 (as gcc-mp-4.7). You can then activate gcc 4.7 as default with

sudo port select gcc mp-gcc47
hash gcc

To go back to the Apple LLVM compiler

sudo port select gcc none
hash gcc

Manual installation

Otherwise you can download the tarball from and follow the instructions in the INSTALL file (usually ./configure; make; make install) but you will have to install all the dependencies by yourself.

A manual installation will (if not specified differently with configure) install the binaries in /usr/local/bin.

share|improve this answer
Okay, I've done that, Homebrew is still saying that I'm using the Apple compiler, how can I change that within Homebrew, or just even regular Terminal? – MarcusJ Dec 12 '12 at 18:06
Ok by that you mean MacPorts or the manual installation? – Matteo Dec 13 '12 at 13:04
@MarcusJ I updated the answer with some post-installation instructions – Matteo Dec 13 '12 at 13:13
I used the Macports method, thanks for the added instruction, I'll try it out in a few hours when I get home. – MarcusJ Dec 13 '12 at 18:57
Thanks for that command to select the proper GCC version, it appears that that is only MacPorts wide though? – MarcusJ Dec 13 '12 at 22:19

Download a signed Installer package here:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .