在CentOS 6.0 編譯 GNU GCC 4.8.1

安裝mcrouter前必須安裝 gcc 4.8+
詳見

但是我手邊只有CentOS6.0的機器,只好硬餵他吃 gcc 4.8.1

下載gcc要的版本

直接開始compile看看,結果出現
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. 
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations.  
Source code for these libraries can be found at their respective hosting sites as well as 
at ftp://gcc.gnu.org/pub/gcc/infrastructure/

少三個相依lib,去 ftp://gcc.gnu.org/pub/gcc/infrastructure/ 補齊

  1. gmp-4.3.2.tar.bz2 
  2. mpfr-2.4.2.tar.bz2 
  3. mpc-0.8.1.tar.gz
安裝 gmp-4.3.2

# bunzip2 gmp-4.3.2.tar.bz2
# tar -zxvf gmp-4.3.2.tar
# cd gmp-4.3.2
# ./configure --prefix=/usr/local/gmp-4.3.2
# make
# make install

安裝 mpfr-2.4.2 (需要gmp-4.3.2)

# bunzip2 mpfr-2.4.2.tar.bz2
# tar -zxvf mpfr-2.4.2.tar
# cd mpfr-2.4.2
# ./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2/
# make
# make install

安裝mpc-0.8.1 (需要gmp-4.3.2、mpfr-2.4.2)
# tar -zxvf mpc-0.8.1.tar.gz
# cd mpc-0.8.1
#./configure --prefix=/usr/local/mpc-0.8.1/ --with-gmp=/usr/local/gmp-4.3.2/ --with-mpfr=/usr/local/mpfr-2.4.2
# make
# make install

安裝 glibc-devel
# yum install glibc-devel


最後安裝 GNU CC 4.8.1
# tar -zxvf  gcc-4.8.1.tar.gz
# cd gcc-4.8.1
# mkdir build-gcc
# cd build-gcc
# ../configure --prefix=/usr/local/gcc-4.8.1 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2
# make
# make install


Issue

fatal error: gnu/stubs-32.h: No such file or directory
沒有安裝32bit的 glibc-devel
# yum install glibc-devel.i686

Error while loading shared libraries: libmpc.so.2:
找不到 libmpc.so.2
# vi ~/.bashrc
加一行
export PATH=/usr/local/gmp-4.3.2/lib:$PATH
# source ~/.bashrc




留言