How to Install GCC on Your Mac
GCC, GNU Compiler Collection, is a collection of compilers and related tools for compiling and running programs written in various programming languages, including C, C++, Objective-C, Fortran, Go, D, Ada, and others. It is an open-source project. Your Mac does not come with GCC, but you can install it easily by following the steps below.
Requirements for installing GCC
- Command Line Tools for Xcode (The first step below involves installing this. If you already have it, you can skip this step.)
- Homebrew (The second step below describes installing Homebrew. If you already have Homebrew installed, skip the second step.)
- The most recent macOS version and an Internet connection, as GCC will be downloaded over the Internet
Install GCC
I explain this in three steps. The first step is to install Command Line Tools, the second is to install Homebrew, and the third is to install GCC.
- Open Terminal and enter the following command to install Command Line Tools:
xcode-select --install
- Now, let’s install Homebrew by executing the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Now, it is time to install GCC. Type the following command and hit enter. Please note that several things will be downloaded and installed, so this can take some time:
brew install gcc

Now that you have installed GCC, you will see the following screen:
If you want to be sure that the installation was successful, enter the following command:
gcc --version
If you want to uninstall GCC later to free up storage, you can use the following code:
brew uninstall gcc
Related articles