Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

up vote 9 down vote accepted

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.

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: https://www.litebeam.net/macosx/macosx/gcc.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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