⚡ This is the AMP version of this page. View full version

GCC

Published: 7/7/2025 | Updated: 7/7/2025

How to Set GCC as Default Compiler (Homebrew on macOS)

1. Check Current Compiler

gcc --version

This will give output like:

Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

2. Install GCC Using Homebrew

brew install gcc
gcc-15 --version

This should point to the Homebrew version.


3. Set Homebrew GCC as Default

cd /opt/homebrew/bin
ln -s gcc-15 gcc
ln -s g++-15 g++

4. Verify Default GCC/G++

where gcc

Example output:

/opt/homebrew/bin/gcc
/usr/bin/gcc