How to obtain a GCC on Mac OS X 10.11.6

I have to start coding in C next term (for school) and all of the tutorials on how to install a GCC compiler on Mac involve getting the Xcode app. Unfortunately, whenever I go to download it, it tells me "Xcode can’t be installed on “Macintosh HD” because OS X version 10.12.6 or later is required" and mine is OS X version 10.11.6. I was wondering if there was another way of installing a GCC compiler.

MacBook Air, OS X El Capitan (10.11.6)

Posted on Dec 25, 2017 4:23 PM

Reply
3 replies

Dec 25, 2017 4:37 PM in response to notpmharper

Sign up for a "Free" Developer account

<https://developer.apple.com/register/index.action>


Then go to

<https://developer.apple.com/download/more>

and get a version of Xcode that works on your system. Xcode 4.2 may work, if not, get an older version.

Also get the command line tools.


NOTE: Somewhere along the way, Apple switched to the "clang" compilers. So if the command 'gcc' does not work, try just 'cc'

Dec 28, 2017 4:09 AM in response to notpmharper

Apple does not include the actual GNU C/C++ compiler in the command-line tool for Xcode, or Xcode itself. There is a gcc/g++ "compatibility" command that is available, but it is a special build of clang/clang++ that is using older gcc compatibility (--with-gxx-include-dir) include files.


If your school expects you to be using the current GNU C/C++ compiler (7.2.0), or a specific other version of it, then you will need the Apple clang/clang++ compiler installed, in order to compile the GNU C/C++ compiler. This compilation could take an hour depending on your particular Mac.


Here are the steps:

  1. Sign up for the free Apple Developer account per Bob Harris suggestion. Use the same Apple ID/password that you use to sign into this community when you set up that account.
  2. For El Capitan (10.11.6) you will need one or both of the following from developer.apple.com/download/more:
    1. Xcode 8.2.1 (last release for El Capitan)
    2. Command Line Tools (macOS 10.11) for Xcode 8.2 (last release for El Capitan)
    3. Programmer's editor if you do not plan to use Xcode

      BBEdit, Sublime Text 3, Komodo Edit, Visual Studio Code, MacVim, etc.

  3. To get the real GNU C/C++ package (and its libraries) installed into the /usr/local tree:
    1. Install Homebrew package manager
      $ brew update
      $ brew upgrade
      $ brew search gcc # this will show several versions of it
      $ brew info gcc # specific information on the current compiler including dependencies
      $ brew install gcc # your MacBook Air on the charger
      $ brew cleanup # free up disk space. Only run after brew upgrade has installed newer versions
    2. Visit the GNU Compiler site for documentation, and other information


Above all, comply with your schools requirements especially with the version of compiler.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to obtain a GCC on Mac OS X 10.11.6

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.