Compile gcc4.8 on Ubuntu 12.04 LTS X64

1)  Download gcc-4.8 source code from one of the server in http://gcc.gnu.org/mirrors.html. say:

wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2.tar.bz2

2) Download "mpc, mpfr, gmp" source code.

wget http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz
wget  http://www.mpfr.org/mpfr-current/mpfr-3.1.2.tar.gz
wget http://ftp.gmplib.org/gmp/gmp-5.1.3.tar.bz2

3) Install m4

sudo apt-get install m4

4) Build gmp
 x. sudo mkdir -p /usr/gcc48
 a. tar xjvf gmp-5.1.3.tar.bz2
 b. cd gmp-5.1.3
 c. ./configure --prefix=/usr/gcc48
 d. make
 e. sudo make install 

5) Build mpfr
 a. tar xzvf mpfr-3.1.2.tar.gz
 b. cd mpfr-3.1.2
 c. ./configure --prefix=/usr/gcc48 --with-gmp=/usr/gcc48
 d. make
 e. sudo make install 

6) Build mpc
 a. tar xzvf mpc-1.0.1.tar.gz
 b. cd mpc-1.0.1
 c. ./configure --prefix=/usr/gcc48 --with-mpfr=/usr/gcc48 --with-gmp=/usr/gcc48
     # sudo ln -s /usr/gcc48/lib/libgmp.la /usr/local/lib/libgmp.la 
 d. make
 e. make install

7) Build gcc
 a. tar xjvf gcc-4.8.2.tar.bz2
 b. cd tar xjf gcc-4.8.2
 c. ./configure
 --prefix=/usr/gcc48 --with-gmp=/usr/gcc48 --with-mpfr=/usr/gcc48 --with-mpc=/usr/gcc48 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-4.8
 d. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/gcc48/lib # include mpfr, mpc, gmp etc lib path
 e. make
 f. sudo make install

8) Add the following lines to ~/.bashrc file
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/gcc48/lib:/usr/gcc48/lib64
LD_RUN_PATH=$LD_RUN_PATH:/usr/gcc48/lib64

9) Test the new compiler

http://www.multiprecision.org/index.php?prog=mpc&page=download
http://www.mpfr.org/mpfr-current/#download
http://gmplib.org/

你可能感兴趣的:(Compile gcc4.8 on Ubuntu 12.04 LTS X64)