前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS6 升级gcc:源码编译安装gcc4.6和gcc4.8

CentOS6 升级gcc:源码编译安装gcc4.6和gcc4.8

作者头像
程裕强
发布2022-05-06 10:49:55
1.9K0
发布2022-05-06 10:49:55
举报
文章被收录于专栏:大数据学习笔记

因为某些软件需要高版本的gcc,可以按照需求升级到gcc4.6或者gcc4.8

一、编码编译安装gcc4.6

1、查看当前操作系统版本

[root@master ~]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)

2、下载gcc、gmp和mpfr

[root@master ~]# wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.1/gcc-4.6.1.tar.bz2

[root@master ~]# wget ftp://gcc.gnu.org/pub/gcc/infrastructure/{gmp-4.3.2.tar.bz2,mpc-0.8.1.tar.gz,mpfr-2.4.2.tar.bz2}

代码语言:javascript
复制

3、编译gmp

[root@master ~]# tar -jxf gmp-4.3.2.tar.bz2  [root@master ~]# cd gmp-4.3.2

[root@master gmp-4.3.2]# ./configure --prefix=/usr/local/gmp

[root@master gmp-4.3.2]# make &&make install

4、编译mpfr

[root@master ~]# tar -jxf mpfr-2.4.2.tar.bz2 [root@master ~]# cd mpfr-2.4.2

[root@master mpfr-2.4.2]# ./configure --prefix=/usr/local/mpfr -with-gmp=/usr/local/gmp

[root@master mpfr-2.4.2]# make &&make install

5、编译mpc

[root@master ~]# tar -zxvf mpc-0.8.1.tar.gz

[root@master ~]# cd mpc-0.8.1

[root@master mpc-0.8.1]# ./configure --prefix=/usr/local/mpc -with-mpfr=/usr/local/mpfr -with-gmp=/usr/local/gmp

[root@master mpc-0.8.1]# make &&make install

6、编译gcc-4.6

[root@master ~]# tar -jxf gcc-4.6.1.tar.bz2

[root@master  ~]# cd gcc-4.6.1

[root@master gcc-4.6.1]# ./configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr/ --with-mpc=/usr/local/mpc/

[root@master gcc-4.6.1]# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib/

[root@master gcc-4.6.1]# make && make install

make[4]: Leaving directory `/root/gcc-4.6.1/x86_64-unknown-linux-gnu/libgomp' make[3]: Leaving directory `/root/gcc-4.6.1/x86_64-unknown-linux-gnu/libgomp' make[2]: Leaving directory `/root/gcc-4.6.1/x86_64-unknown-linux-gnu/libgomp' make[1]: Leaving directory `/root/gcc-4.6.1'

7、新建软链接

[root@master gcc-4.6.1]# mkdir -p /usr/bin/gcc_backup/ [root@master gcc-4.6.1]# mv /usr/bin/{gcc,g++} /usr/bin/gcc_backup/ [root@master gcc-4.6.1]# ln -s /usr/local/gcc/bin/gcc /usr/bin/gcc [root@master gcc-4.6.1]# ln -s /usr/local/gcc/bin/g++ /usr/bin/g++

8、查看gcc版本

[root@master gcc-4.6.1]#  gcc --version gcc (GCC) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

二、源码编译安装gcc4.8

1、下载gcc-4.8.2.tar.bz2

[root@master ~]# wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2

[root@master ~]# tar -jxvf gcc-4.8.2.tar.bz2

[root@master ~]# cd gcc-4.8.2

2、下载配置依赖库 [root@master gcc-4.8.2]# ./contrib/download_prerequisites

3、编译目录

[root@master gcc-4.8.2]# mkdir gcc-build-4.8.2 [root@master gcc-4.8.2]# cd gcc-build-4.8.2

4、configure [root@master gcc-build-4.8.2]# ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib

configure: creating ./config.status config.status: creating Makefile

5、make

[root@master gcc-build-4.8.2]# yum install -y glibc-devel.i686 glibc-devel

[root@master gcc-build-4.8.2]# make

true  DO=all multi-do # make make[4]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[3]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[2]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[1]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2'

6、 make install [root@master gcc-build-4.8.2]#  make install

---------------------------------------------------------------------- make[4]: Nothing to be done for `install-data-am'. make[4]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[3]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[2]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2/x86_64-unknown-linux-gnu/libatomic' make[1]: Leaving directory `/root/gcc-4.8.2/gcc-build-4.8.2'

7、查看版本 [root@master gcc-build-4.8.2]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib Thread model: posix gcc version 4.8.2 (GCC) 

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-12-25,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档