Installing GCC 47 on the Mac

  1. Download the MacPorts installer from and install it.
  2. Make sure that you also run the sudo port selfupdate command in terminal as described in the installation instructions for MacPorts.
  3. Open a new window in
  4. Run the command sudo xcodebuild -license
  5. Run the command sudo port install gcc47 +universal. Note: This step will take a number of hours to complete, and at least 4GB of free memory are required to install gcc and build it (the final build takes a bit more than 2GB).
  6. It turns out that MacPorts gcc4.7 do not provide all of the files that it once did. For this reason you'll need to download and install some additional files:
    1. Download this zip file.
    2. Unzip and open the resulting folder.
    3. In Terminal type open /opt/local/lib/gcc47
    4. Copy the two files from the 64-bit folder into this folder.
    5. Locate the i386 folder and open it.
    6. Copy the two files from the 32-bit folder into this folder.
    7. Close the Finder window (this is not a Finder window that you normally want to tamper with.

Why Do This?

  • Different versions of the Mac OS and Xcode versions include a variety (and omit a variety) of compilers. We all use different OS and Xcode versions and can't hope to all be compatible with each other. By using the same compiler from MacPorts we can actually all be compatible with each other and not waste time trying figure out compiler differences.
  • GCC 4.7 produces faster / more-optimized code than the compilers currently shipping with Xcode
  • GCC 4.7 supports more of the C++11 standard, which makes a lot of mundane coding tasks easier and less buggy
  • At one point Tim made a GCC 4.6 installer, compiling everything from scratch -- it is too much work for us to continue maintaining such a monstrosity. Additionally, we had not worked out the best way to deal with dependencies on the standard C++ library that was compiled from that.
  • GCC 4.7 builds code much faster than some of the other compilers we've been using - C++ libraries for gcc 4.7 (3.84 MB) Trond Lossius, 2012-11-09 12:08 am