MacOS – installing old version of c++ compiler

gccmacosxcode

I use OSX 10.10.5 need to compile some c++ code with an old version of gcc, namely 4.3.4. I don't think XCode provide that kind of tools. I suppose there is a way to do that by hand. How can I do that ?

Best Answer

I have compiled older gcc in the past as a last resort.

  1. Get Xcode - it gives you clang and lots of header files. If you can't stomach it, get the command line tools.
  2. Get http://brew.sh
  3. brew install gcc

From there you can see if an older gcc is available or worst case, pull that source and compile it from the version of gcc you have running from above. It looks like you'll be able to use homebrew to get at the version 4.3 from the versioned source already in the tool:

mac:~ me$ brew search gcc
gcc
homebrew/dupes/apple-gcc42       homebrew/versions/gcc44          homebrew/versions/gcc47          homebrew/versions/gcc5
homebrew/head-only/gccxml        homebrew/versions/gcc45          homebrew/versions/gcc48          homebrew/versions/llvm-gcc28
homebrew/versions/gcc43          homebrew/versions/gcc46          homebrew/versions/gcc49