I have recently become frustrated with the new clang compiler included with Xcode 5. I was wondering what the best way to install GNU GCC on OS X would be.
Things to
Use a pre-compiled binary specifically for OS X 10.9.x Mavericks:
→ gcc-4.9
Compiled using source code from the GNU servers.
This contains current versions (4.7 is the stable release) of gfortran (free, open source, GNU Fortran 95 compiler), gcc (GNU C) and g++ (GNU C++) compilers that can perform auto-vectorization (i.e. modify code to take advantage of AltiVec/SSE, automatically) and other sophisticated optimizations like OpenMP. For more information, see this webpage.
Download my binaries, and cd to the download folder. Then gunzip gcc-4.9-bin.tar.gz (if your browser didn't do so already) and then sudo tar -xvf gcc-4.9-bin.tar -C /. It installs everything in /usr/local. You can invoke the Fortran 95 compiler by simply typing gfortran. You will also need to have Apple's XCode Tools installed from the Mac App Store. With XCode 4 or 5 you will need to download the command-line tools as an additional step. You will find the option to download the command-line tools in XCode's Preferences.
On 10.9 Mavericks, you can get the command-line tools by simply typing xcode-select --install.