1、环境介绍

[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64

2、下载gcc-5.4.0源码包

[root@localhost ~]# wget http://mirrors.nju.edu.cn/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.gz
[root@localhost ~]# tar xf gcc-5.4.0.tar.gz
[root@localhost ~]# cd gcc-5.4.0/
[root@localhost gcc-5.4.0]# ./contrib/download_prerequisites
"./contrib/download_prerequisites会下载mpfr-2.4.2.tar.bz2 gmp-4.3.2.tar.bz2 mpc-0.8.1.tar.gz isl-0.14.tar.bz2这四个文件"
"下方的tar包里面已经创建好了gcc-build-5.4.0,执行./contrib/download_prerequisites所下载的依赖包也都下载好了,解压后,可以直接开始编译,包的大小为132.97MB"
"链接:https://pan.baidu.com/s/1bEQNC20SLQ3-psEirAzfVg"
"提取码:bfwg"

3、编译安装gcc

[root@localhost gcc-5.4.0]# mkdir gcc-build-5.4.0
[root@localhost gcc-5.4.0]# cd gcc-build-5.4.0/
[root@localhost gcc-build-5.4.0]# ../configure --enable-checking=release \
--enable-languages=c,c++ \
--with-arch_32=x86-64 \
--build=x86_64-redhat-linux \
--disable-multilib
[root@localhost gcc-build-5.4.0]# make && make install
"make && make install执行了大约1小时,可以喝喝茶,看看手机,站起来转两圈"

4、验证gcc版本

[root@localhost ~]# /usr/local/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-redhat-linux/5.4.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --with-arch_32=x86-64 --build=x86_64-redhat-linux --disable-multilib
Thread model: posix
gcc version 5.4.0 (GCC)
"编译的gcc在/usr/local/bin目录下,/usr/bin/gcc的版本依旧还是4.8.5的"

5、更新gcc连接

"保留一下4.8.5的gcc,后续需要回退的时候,可以方便很多"
[root@localhost ~]# mv /usr/bin/gcc{,-4.8.5}
[root@localhost ~]# mv /usr/lib64/libstdc++.so.6{,-4.8.5}
[root@localhost ~]# mv /usr/bin/g++{,-4.8.5}
[root@localhost ~]# ln -s /usr/local/bin/gcc /usr/bin/gcc
[root@localhost ~]# ln -s /usr/local/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6
[root@localhost ~]# ln -s /usr/local/bin/g++ /usr/bin/g++
"这个时候gcc -v就可以看到gcc的版本变成5.4了"
[root@localhost ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-redhat-linux/5.4.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-checking=release --enable-languages=c,c++ --with-arch_32=x86-64 --build=x86_64-redhat-linux --disable-multilib
Thread model: posix
gcc version 5.4.0 (GCC)

CentOS 7 升级 gcc-4.8.5 到 gcc-5.4.0的更多相关文章

  1. CentOS 7 升级gcc/g++编译器

    gcc的升级必须要使用源码进行升级,也就说,必须要使用源码进行编译才行.我的7.2的CentOS目前自带的gcc是4.8.5的,gcc从4.8之后开始支持C++11,但是鉴于现在C++14.C++17 ...

  2. centos 6升级 GCC 到4.8

    centos 6升级 GCC 到4.8   安装最新版本的swoole 提示 pecl install swolle ... GCC 4.8 or later required. 首先想到的时候yum ...

  3. centos 7升级gcc到10.2.0

    安装gcc 由于 Linux 操作系统的自由.开源,在其基础上衍生出了很多不同的 Linux 操作系统,如 CentOS.Ubuntu.Debian 等.这些 Linux 发行版中,大多数都默认装有 ...

  4. CENTOS 7 升级安装 Python 3.5

    写在前面的话 本文采取源码的方式安装 Python 3.5.2,如果是其它版本会有或多或少的差异,且写这篇的时候官网最新的是 Python 3.7,个人使用 3.5 就足够了,没必要更新到最新,否则出 ...

  5. CentOS如何升级openssl到最新版本

    本文不再更新,可能存在内容过时的情况,实时更新请移步原文地址:CentOS如何升级openssl到最新版本: 环境信息 CentOS Linux release 7.6.1810 (Core): Op ...

  6. centos 7 升级后yum install出现Exiting on user cancel

    centos 7 升级后yum install出现Exiting on user cancel centos 7.x升级后用yum install进行安装时经常出现Exiting on user ca ...

  7. CentOS 7升级Python到3.5后yum出错

    CentOS 7升级Python到3.5后,我跟以前CentOS 6一样,在/usr/bin/python创建了一个指向Python 3的软连接,然后将/usr/bin/yum的顶部的: !/usr/ ...

  8. 关闭centos自动升级内核

    八.关闭Centos自动更新chkconfig --list yum-updatesd  #显示当前系统状态yum-updatesd    0:关闭  1:关闭  2:启用  3:启用  4:启用  ...

  9. Linux:centos内核升级

    centos内核升级 centos升级2.6内核到3.10 在yum的ELRepo源中,有 m ain l ine(3.13.1). l ong- t erm(3.10.28)这2个内核版本,long ...

  10. centos yum升级php

    centos yum升级php5.3.3到最5.6.3 不要轻易升级,否则后果很严重! 注意事项: 1 升级后之前的php扩展不会丢失 自动会安装对应最新php的扩展2 升级后需重启下apache 才 ...

随机推荐

  1. 使用 try-catch

    ECMA-262 第 3 版引入了 try-catch 语旬,当 try-catch 语句中发生错误时, 浏览器会认为错误已经被处理了 ,因而不会报告错误.对于那些不要求用户懂技术,也不需要用户理解错 ...

  2. Java无包结构命令行编译

    无包结构的命令行编译运行方式 如果图片损坏,点击链接:https://www.toutiao.com/i6491250431673500173/ 利用记事本编写一段简单的代码,文件名和类名要一致. 将 ...

  3. LINUX学习-Mysql集群-主主备份

    接着主从备份继续. 1.编辑主从服务器 vim /etc/my.cnf 在server-id下添加一句 忽略一些信息 binlog-ignore-db=mysql 2.从服务器也授权给主服务器 gra ...

  4. 白话TCP/IP原理

    TCP/IP(Transmission-Control-Protocol/Internet-Protocol),中文译名为传输控制协议/因特网互联协议,又名网络通讯协议,是Internet最基本的协议 ...

  5. Java将引入新的对象类型来解决内存利用问题

    2022年Java将有什么新的特性和改进,我相信很多Java开发者都想知道.结合Java语言架构师布莱恩·格茨(Brian Goetz)最近的一些分享,胖哥给大家爆个料.老规矩,点赞走起. Valha ...

  6. 【初体验】valgrind分析程序性能

    wget https://fossies.org/linux/misc/valgrind-3.15.0.tar.bz2 tar -jxvf valgrind-3.15.0.tar.bz2 cd val ...

  7. Using Swap

    # create swap file dd if=/dev/zero of=/.swap bs=1048576 count=4096 # format swap mkswap /.swap # sta ...

  8. 深入理解http1.x、http 2和https

    转自 https://segmentfault.com/a/1190000015316332 一.HTTP/1.x Http1.x 缺陷:线程阻塞,在同一时间,同一域名的请求有一定数量限制,超过限制数 ...

  9. 阿里Java规范:【强制】所有的 POJO 类属性必须使用包装数据类型

    在 Java 开发手册中有这一条: 我们知道基本类型和包装类型有很多不同点: 封装类型可以调用各种方法,而基本类型没有 封装类型声明字段之后可以不设置默认值,而基本类型需要初始化默认值.比如 int ...

  10. netty系列之:请netty再爱UDT一次

    目录 简介 netty对UDT的支持 搭建一个支持UDT的netty服务 异常来袭 TypeUDT和KindUDT 构建ChannelFactory SelectorProviderUDT 使用UDT ...