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:
- 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.
- For El Capitan (10.11.6) you will need one or both of the following from developer.apple.com/download/more:
- Xcode 8.2.1 (last release for El Capitan)
- Command Line Tools (macOS 10.11) for Xcode 8.2 (last release for El Capitan)
- Programmer's editor if you do not plan to use Xcode
BBEdit, Sublime Text 3, Komodo Edit, Visual Studio Code, MacVim, etc.
- To get the real GNU C/C++ package (and its libraries) installed into the /usr/local tree:
- 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
- Visit the GNU Compiler site for documentation, and other information
Above all, comply with your schools requirements especially with the version of compiler.