Main

Installing Gcc Compilers On Mac OSX

Before you begin, make sure you have XCode and the XCode command-line tools (e.g., make).

If you don't have Mac Ports or Homebrew on your Mac, install one of them. Both provide many Unix libraries and applications that do not normally come with your OS.

Important: Pick just one! Having both can cause issues with some packages because both Brew and Ports use /opt/local.

Using Homebrew

  • Install Homebrew (http://brew.sh/) if you don't have it already.
  • Pick a version of GCC you wish to install, anything greater than 5 should be fine, e.g., to install v. 7, run the following in Terminal:
brew tap homebrew/versions
brew install gcc7

Check /opt/local/bin for the gcc-7 executable; add /opt/local/bin to your PATH if it's not already there. You can also alias gcc to the gcc-7 executable to avoid having to type the version every time.

Using Mac Ports

  • Install Mac Ports (https://www.macports.org/install.php) if you don't have it already.
  • Pick a version of GCC you wish to install, anything greater than5 should be fine, e.g., to install v. 7, run the following in Terminal. It will take a long time, make sure you have power and Internet access.
sudo port selfupdate
sudo port install gcc7
sudo port select --set gcc mp-gcc7

Check /opt/local/bin for the gcc-mp-7 executable; add /opt/local/bin to your PATH if it's not already there. You can compile with gcc sourcename.c. To see all versions you have installed, you can use port select --list gcc

Green Marinee theme adapted by David Gilbert, powered by PmWiki