How do I install GCC 4.7.2 on OS X 10.8?

21,714

Solution 1

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.

Solution 2

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

Share:
21,714

Related videos on Youtube

MarcusJ
Author by

MarcusJ

Updated on September 18, 2022

Comments

  • MarcusJ
    MarcusJ over 1 year

    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

    • David Schwartz
      David Schwartz over 11 years
      Download gcc 4.7.2. Build it according the instructions. Install it according to the instructions.
  • MarcusJ
    MarcusJ over 11 years
    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?
  • Matteo
    Matteo over 11 years
    Ok by that you mean MacPorts or the manual installation?
  • Matteo
    Matteo over 11 years
    @MarcusJ I updated the answer with some post-installation instructions
  • MarcusJ
    MarcusJ over 11 years
    I used the Macports method, thanks for the added instruction, I'll try it out in a few hours when I get home.
  • MarcusJ
    MarcusJ over 11 years
    Thanks for that command to select the proper GCC version, it appears that that is only MacPorts wide though?