Things you’ll need:
- Knowledge of how to use the terminal
- An internet connection
- A Mac developer account (you can get this as we go along)
- Copy of Xcode (free)
- About an hour of your time (30 minutes downloading, 15-30 minutes doing things)
- Download and install Xcode
- Download command line tools
- Download and install gfortran from other source
error trying to exec `as': execvp: No such file or directory
Also note that I performed this installation on a Macbook Air.
Download and install Xcode by clicking this link, or by searching for it in the Apple App Store, where it can be downloaded for free (see image).
After you’ve downloaded Xcode, you’ll want to open it and agree to their terms of service. Then, you’ll want to navigate to the menu Xcode –> Preferences –> Downloads. Here you’ll see an option to download Command Line Tools (see image). Note that you’ll need a developer account at this stage, and I was redirected to their developer page where I had to fill out a form and create my account (using my existing Apple ID, where a lot of the form was already auto-filled).
After you have successfully installed the command line tools, open your terminal and type something like:
$ which gcc
which should return the path of your gcc in /usr/local/bin. All of this should have been taken care of automatically.
I mentioned at the beginning that I got an error when attempting to use gfortran on my machine before I’d even installed gcc. I found that gcc must be installed in order to use gfortran. But my gfortran installation went smooth because it’s very straightforward.
After considering my hardware, I chose the option:
Mac OS Lion (10.7) on Intel 64-bit processors (gfortran 4.6.2): download (released on 2011-10-20)
The installation has a walkthrough that comes with the package, like many Mac installations. Straightforward and it should also work automatically. Then, open your terminal and type
$ which gfortran
and it should reveal that it was successfully installed in /usr/local/bin.