Build & Install GCC4.6.1 in CentOS(5.2 or 6.3 are both verified)

jackywei edited this page Nov 5, 2012 · 1 revision

I did not know if you have already installed gmp, mpfr, mpc before build gcc4.6, if you did not, please refer to these to build GCC4.6.1:

1. build & install gmp:

tar jxf gmp-4.3.2.tar.bz2 &&cd gmp-4.3.2/

./configure --prefix=/usr/local/gmp

make &&make install

cd ..

2. build & install mpfr:

tar jxf mpfr-2.4.2.tar.bz2 ;cd mpfr-2.4.2/

./configure --prefix=/usr/local/mpfr -with-gmp=/usr/local/gmp

make &&make install

cd ..

3. build & install mpc:

tar xzf mpc-0.8.1.tar.gz ;cd mpc-0.8.1

./configure --prefix=/usr/local/mpc -with-mpfr=/usr/local/mpfr -with-gmp=/usr/local/gmp

make &&make install

cd ..

After build & install these libs, you could start to build & Install gcc4.6.1:

4. build & install gcc4.6.1

tar jxf gcc-4.6.1.tar.bz2 ;cd gcc-4.6.1

./configure --prefix=/usr/local/gcc -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ -with-gmp=/usr/local/gmp -with-mpfr=/usr/local/mpfr/ -with-mpc=/usr/local/mpc/


[ $? -eq 0 ];then

echo "this gcc configure is success"


echo "this gcc configure is failed"


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/

make && make install

[ $? -eq 0 ] && echo install success

5. set up the gcc env:

-- this is really important. or even you successfully built the GCC, you could not build hhvm successfully. the gcc.4.6.1.conf - please find the attachment.

cp gcc.4.6.1.conf /etc/


mv /usr/bin/gcc /usr/bin/gcc_old

mv /usr/bin/g++ /usr/bin/g++_old

ln -s -f /usr/local/gcc/bin/gcc /usr/bin/gcc

ln -s -f /usr/local/gcc/bin/g++ /usr/bin/g++

cp /usr/local/gcc/lib64/ /usr/lib64/.

mv /usr/lib64/ /usr/lib64/

ln -s -f /usr/lib64/ /usr/lib64/

6. finished.

you could run gcc --version to check if the current gcc version is gcc4.6.1, and also need to check g++, to see if the version is changed to g++4.6.1 too.

and then you could make your hhvm.