Mac OSX uses clang instead of gcc as the default C compiler. We can manually compile and install gcc in OSX.

Dependency

  • GMP: GNU Multiple Precision Arithmetic Library
  • MPFR: Multiple-Precision Floating-point computations with correct Rounding
  • MPC: C library for the arithmetic of complex numbers

Install GMP and MPFR by homebrew

brew install gmp mpfr

Install MPC by source code

(the mpc version in homebrew is too old)

wget http://mirror.cs.nctu.edu.tw/gnu/mpc/mpc-1.0.2.tar.gz
tar zxf mpc-1.0.2.tar.gz
cd mpc-1.0.2
./configure
make
sudo make install

Install gcc

There seems to be some problem in 4.9.0

wget http://mirror.cs.nctu.edu.tw/gnu/gcc/gcc-4.8.1/gcc-4.8.1.tar.bz2
tar jxvf gcc-4.8.1.tar.bz2
cd gcc-4.8.1
./configure --prefix=/usr/local/gcc --enable-languages=c,c++
make DESTDIR=/usr/local/gcc BOOT_CFLAGS='-O' bootstrap
sudo make install

Reference