You are currently viewing Install GCC-12/G++-12 on macOS Apple M1

Install GCC-12/G++-12 on macOS Apple M1

Apple began the transition from Intel processors to Apple silicon (i.e., Apple M1 ARM64) in Mac computers [1]. Thus, the 15-year partnership with Intel is about to be ended [2].

In the other side, Intel introduced Intel oneAPI – an unified and cross-architecture performance programming model [3], without supporting new Apple chips. This challenges developers who need to use Intel Fortran Compiler [4] which only supports products using Intel processors.

A solution just come!

GNU Compiler Collection GCC 12.1 was released on May 6, 2022 [5] that support Fortran compilers on AArch64 (i.e., ARM64) architectures.

How to install GCC 12.1 on macOS M1?

gcc, g++

Open Terminal and check gcc --version, returns clang compiler only.

Install Homebrew, see instruction here.

Check brew version: brew --version.

Install GCC 12.1: brew install gcc@12.

Check GCC 12.1 installation: gcc-12 --version.

Go to its install location: cd /opt/homebrew/bin.

Make soft/symbolic links: ln -s gcc-12 gcc and ln -s g++-12 g++.

Check the gcc and g++ priorities and location: where gcc.

Exit and reinitiate the terminal, type in gcc --version returns the GCC 12.1 version through Homebrew installation.


Check the version of gfortran: gfortran --version, still point to old version gfortran-11 within gcc-11.

Go to its install location: cd /opt/homebrew/bin.

Make soft/symbolic links: ln -sf gfortran-12 gfortran. The -f option remove existing destination files (if any) before creating the link [6].



Leave a Reply