Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Data / SNooPy / Compiling Code in OSX

Compiling Code in OSX

It seems that with every new release of OSX, life gets harder and harder for us coders. Below are some notes on prep work you need to do to get to a point where you can compile C and FORTRAN code.

All versions:

First, you need to install Xcode. Go to the App store, search for Xcode and install it. It is free.

You will then need to install a FORTRAN compiler. Go to the High Performance Computing for OSX page and download the appropriate compiler. You install it by un-tar-ing it into the root folder. So, if you downloaded gcc-4.9.bin.tar.gz to your Downloads folder, you could do:

cd /
sudo tar -zxf ~/Downloads/gcc-4.9.bin.tar.gz 

In addition to getting Xcode and the FORTRAN compiler, the more "modern" versions of OSX have some quirks that need addressing:

OSX v. 10.7 (Lion):

  1. Once you've installed Xcode, run it. Then select the Xcode->Preferences... menu item. Up pops a preferences window. Click on the "Downloads" tab and select the "Command Line Tools". Click on the install button.

OSX v. 10.8 (Mountain Lion):

  1. Once you've installed Xcode, run it. Then select the Xcode->Preferences... menu item. Up pops a preferences window. Click on the "Downloads" tab and select the "Command Line Tools". Click on the install button.
  2. X-windows no longer comes with OSX. You will need to download/install Xquartz.

OSX v. 10.9 - 10.13 (Mavericks - High Sierra):

  1. Once you've installed Xcode, open a terminal and run 'xcode-select --install'. You may also have to open the App store, go to Updates and update the "command line tools for OSX".
  2. X-windows no longer comes with OSX. You will need to download/install Xquartz.

OSX v. 10.14 (Mojave):

  1. Once you've installed Xcode, open a terminal and run 'xcode-select --install'. You may also have to open the App store, go to Updates and update the "command line tools for OSX".
  2. Next, run:
    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
  3. X-windows no longer comes with OSX. You will need to download/install Xquartz.