Bootstrap

编译gcc 4.9到用户目录下

当没有root权限,又需要使用gcc高版本时,只好想办法把它编译到$HOME目录中去。
中间的过程经历坎坷,不过终于成功了。记录一下过程,以备以后参考。

  1. 先下载各种代码包,包括gcc, gmp, mpc, mpfr等
  2. 弄个简单的Makefile:
INSTALL_DIR := /home/xxx/local  # 这里安装的主目录,后面各种lib, include都会被装到相应的子目录下

# 各种包的版本                                                                                                                                                                             
GMP := gmp-4.3.2                                                                                                                                                                                     
MPFR := mpfr-2.4.2                                                                                                                                                                                   
MPC := mpc-0.8.1                                                                                                                                                                                     
GCC := gcc-4.9.2                                                                                                                                                                                     

all: gmp mpfr mpc gcc                                                                                                                                                                                

test:                                                                                                                                                                                                
    echo ${INSTALL_DIR}                                                                                                                                                                                     

gmp:                                                                                                                                                                                                 
    tar xf ${GMP}.tar.bz2 && cd ${GMP} && ./configure --prefix=${INSTALL_DIR} && nice -n 19 make -j16 && make install && cd ..                                                                        

mpfr:                                                                                                                                                                                                
    tar xf ${MPFR}.tar.bz2 && cd ${MPFR} && ./configure --prefix=${INSTALL_DIR} --with-gmp=${INSTALL_DIR} && nice -n 19 make -j16 && make install && cd ..                                             

mpc:                                                                                                                                                                                                 
    tar xf ${MPC}.tar.gz && cd ${MPC} && LD_LIBRARY_PATH=${INSTALL_DIR}/lib ./configure --prefix=${INSTALL_DIR} --with-gmp=${INSTALL_DIR} --with-mpfr=${INSTALL_DIR} && LD_LIBRARY_PATH=${INSTALL_DIR}/lib nice -n 19 make -j16 && make install && cd ..                                                                                                                                                       

gcc:                                                                                                                                                                                                 
    tar xf ${GCC}.tar.bz2 && cd ${GCC} && LD_LIBRARY_PATH=${INSTALL_DIR}/lib ./configure --prefix=${INSTALL_DIR} --with-gmp=${INSTALL_DIR} --with-mpfr=${INSTALL_DIR} --with-mpc=${INSTALL_DIR} && LD_LIBRARY_PATH=${INSTALL_DIR}/lib nice -n 19 make -j16 && make install && cd ..                                                                                                                             

clean:                                                                                                                                                                                               
    rm -r ${GMP} ${MPFR} ${MPC} ${GCC} ${INSTALL_DIR}/*
  1. 直接make似乎不行,后来使用LD_LIBRARY_PATH=/home/xxx/local make成功了
;