给公司测试服务器搭环境,手工安装gcc-4.9.0颇费功夫,记录如下。
1、安装gcc、g++,系统源默认安装版本为4.4.7;
2、安装依赖包GMP、MPFR、MPC,注意安装顺序;
3、修改动态库链接路径,加入GMP、MPFR、MPC;
4、编译安装Gcc-4.9,新创建目录gcc-build来存放Make过程产生文件;
5、拷贝Gcc-4.9的头文件至目录/usr/include/c++;
6、修改LD_LIBRARY_PATH、PATH和CPLUS_INCLUDE_PATH;
7、建立新的Gcc、G++软连接。
1、 yum -y install gcc yum -y install gcc-c++ 2、 mkdir /usr/local/gmp-4.3.2 ./configure --prefix=/usr/local/gmp-4.3.2/ make make install mkdir /usr/local/mpfr-2.4.2 ./configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2 make make install mkdir /usr/local/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 3、 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib 4、 mkdir gcc-bulid cd gcc-build ../gcc-4.9.0/configure --prefix=/usr/local/gcc-4.9.0 --exec-prefix=/usr/local/gcc --enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1 --disable-multilib make make install 5、 cp -r /usr/local/gcc-4.9.0/include/c++/4.9.0 /usr/include/c++ 6、 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/mpc-0.8.1/lib:/usr/local/gcc/lib64 export PATH=$PATH:/usr/local/gcc/bin export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/usr/include/c++/4.9.0:/usr/include/c++/4.9.0/x86_64-unknown-linux-gnu 7、 mv gcc gcc-4.4.7 ln -s /usr/local/gcc/bin/gcc ./gcc mv g++ g++-4.4.7 ln -s /usr/local/gcc/bin/g++ g++
时间: 2024-10-09 22:14:03