SUSE11.3 编译gcc4.8.5

1.首先下载gcc4.8.5及其依赖的库gmp,mpfr,mpc的源码放到创建的编译目录:/data/niuhe/gcc4.8.5SUSE11.3 编译gcc4.8.52.依次编译依赖库,将其编译到/data/niuhe/gcc_deps:

进入gmp-6.1.2目录

./configure --prefix=/data/niuhe/gcc4.8.5/gcc_deps

make -j24

make install

进入mpfr-4.0.2目录

./configure --prefix=/data/niuhe/gcc4.8.5/gcc_deps --with-gmp=/data/niuhe/gcc4.8.5/gcc_deps

make -j24

make install

进入mpc-1.1.0目录

./configure --prefix=/data/niuhe/gcc4.8.5/gcc_deps --with-gmp=/data/niuhe/gcc4.8.5/gcc_deps --with-mpfr=/data/niuhe/gcc4.8.5/gcc_deps

make -j24

make install

至此,gcc依赖的库都已经编译好了。

3.配置环境变量

export LD_LIBRARY_PATH=/data/niuhe/gcc4.8.5/gcc_deps/lib/

export LIBRARY_PATH=/data/niuhe/gcc4.8.5/gcc_deps/lib/

export C_INCLUDE_PATH=/data/niuhe/gcc4.8.5/gcc_deps/include/

export CPLUS_INCLUDE_PATH=/data/niuhe/gcc4.8.5/gcc_deps/include/

4.编译gcc4.8.5

创建一个编译目录:gcc-build

进入gcc-build目录,并configure生成makefile

../configure --prefix=/usr/local/gcc-4.8.5 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-4.8

make -j24

make install -j24

自此,gcc4.8.5就编译好了,位于/usr/local/gcc-4.8.5目录

SUSE11.3 编译gcc4.8.5

cmake生成makefile时:

cmake . -DCMAKE_CXX_COMPILER=/usr/local/gcc-4.8.5/bin/g++-4.8 -DCMAKE_C_COMPILER=/usr/local/gcc-4.8.5/bin/gcc-4.8

另外,运行编译好的程序时,依赖/usr/local/gcc-4.8.5/lib64/libstdc++.so.6

需要将该文件放到LD_LIBRARY_PATH环境变量配置的目录中

 

参考:

SUSE Linux Enterprise 11 SP3 成功编译安装GCC 4.8.2

也可以通过软件版本管理指定gcc:linux软件版本管理命令update-alternatives使用详解

 

 
喜欢 0
分享