6

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

  • 1
    Download gcc 4.7.2. Build it according the instructions. Install it according to the instructions. – David Schwartz Dec 10 '12 at 10:54
10

MacPorts

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 gnu.org 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.

  • 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
2

Download a signed Installer package here: https://www.litebeam.net/macosx/macosx/gcc.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.