Linux超详细gcc升级全过程

目录
  • 前言
  • 1.当前gcc版本
  • 2.安装gcc
  • 3.gmp安装
  • 4.MPFR编译
  • 5.MPC编译
  • 6.GCC 配置
  • 7.GCC版本更新

前言

c c++ 等等 需要这个编译器gcc,最近有DBA的朋友咨询RHEL7.6操作系统安装Mysql数据库时需要 高版本的GCC,研究了下发现坑不少,总结本文分享给大家

1.当前gcc版本

[root@rhel76 ~]# 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) 

从以上可以看出当前版本为4.8.5,本次我们升级到10.1.0

2.安装gcc

--下载地址:
https://mirrors.aliyun.com/gnu/gcc/gcc-10.1.0/

[root@rhel76 ~]# tar -vxf gcc-10.1.0.tar.gz
[root@rhel76 gcc-10.1.0]# mkdir build
[root@rhel76 gcc-10.1.0]# cd build/
[root@rhel76 build]# ../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libhsail-rt support... yes
checking for libphobos support... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
https://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.

从日志总可以看出有如下报错,故下面每个都安装
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.

3.gmp安装

[root@jeames007 ~]# tar -vxf gmp-5.0.1.tar.bz2
[root@jeames007 ~]# cd gmp-5.0.1/
[root@jeames007 gmp-5.0.1]# ./configure --prefix=/usr/local/gmp-5.0.1
[root@jeames007 gmp-5.0.1]# make
[root@jeames007 gmp-5.0.1]# make install
make[4]: Leaving directory `/root/gmp-5.0.1'
make[3]: Leaving directory `/root/gmp-5.0.1'
make[2]: Leaving directory `/root/gmp-5.0.1'
make[1]: Leaving directory `/root/gmp-5.0.1'

4.MPFR编译

[root@jeames007 ~]# tar -vxf mpfr-3.1.5.tar.xz

[root@jeames007 ~]# cd mpfr-3.1.5/
[root@jeames007 ~]#./configure --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-5.0.1
[root@jeames007 mpfr-3.1.5]# make
[root@jeames007 mpfr-3.1.5]# make install

5.MPC编译

[root@jeames007 ~]# tar -vxf mpc-1.0.1.tar.gz
[root@jeames007 ~]# cd mpc-1.0.1
[root@jeames007 ~]# ./configure --prefix=/usr/local/mpc-1.0.1 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5
[root@jeames007 mpc-1.0.1]# make
[root@jeames007 mpc-1.0.1]# make install

6.GCC 配置

[root@rhel76 ~]# cd gcc-10.1.0
[root@rhel76 gcc-10.1.0]# cd build/
../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.1

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libhsail-rt support... yes
checking for libphobos support... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... buggy but acceptable
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... yes
checking for isl 0.15 or later... no
required isl version is 0.15 or later
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libphobos target-zlib target-libbacktrace target-libgfortran target-libgo target-libffi target-libobjc target-liboffloadmic
    (Any other directories should still work fine.)
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... no
/root/gcc-10.1.0/missing: line 81: makeinfo: command not found
checking for expect... no
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for otool... no
checking for readelf... readelf
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gfortran... gfortran
checking for gccgo... no
checking for gdc... no
checking for ar... no
checking for ar... ar
checking for as... no
checking for as... as
checking for dlltool... no
checking for dlltool... no
checking for ld... no
checking for ld... ld
checking for lipo... no
checking for lipo... no
checking for nm... no
checking for nm... nm
checking for objcopy... no
checking for objcopy... objcopy
checking for objdump... no
checking for objdump... objdump
checking for otool... no
checking for otool... no
checking for ranlib... no
checking for ranlib... ranlib
checking for readelf... no
checking for readelf... readelf
checking for strip... no
checking for strip... strip
checking for windres... no
checking for windres... no
checking for windmc... no
checking for windmc... no
checking where to find the target ar... host tool
checking where to find the target as... host tool
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gfortran... host tool
checking where to find the target gccgo... host tool
checking where to find the target gdc... host tool
checking where to find the target ld... host tool
checking where to find the target lipo... host tool
checking where to find the target nm... host tool
checking where to find the target objcopy... host tool
checking where to find the target objdump... host tool
checking where to find the target otool... host tool
checking where to find the target ranlib... host tool
checking where to find the target readelf... host tool
checking where to find the target strip... host tool
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

[root@jeames007 ~]# make -j4
make 时间很长,很长,耐心等待,本人编译了1个小时。所以有条件的话,在编译时,可以使用make -j8

[root@jeames007 build]# make install

此时GCC版本还未更新下,需要以下的操作

7.GCC版本更新

mv /usr/bin/gcc /usr/bin/gcc485
mv /usr/bin/g++ /usr/bin/g++485
mv /usr/bin/c++ /usr/bin/c++485
mv /usr/bin/cc /usr/bin/cc485

ln -s /usr/local/gcc-10.1.0/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-10.1.0/bin/g++ /usr/bin/g++
ln -s /usr/local/gcc-10.1.0/bin/c++ /usr/bin/c++
ln -s /usr/local/gcc-10.1.0/bin/gcc /usr/bin/cc

mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bak
ln -s /usr/local/gcc-10.1.0/lib64/libstdc++.so.6.0.28 /usr/lib64/libstdc++.so.6

脚本执行成功之后就可以查看当前使用的gcc版本了  查看的命令:gcc -v

[root@jeames007 ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-10.1.0/libexec/gcc/x86_64-pc-linux-gnu/10.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/usr/local/gcc-10.1.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-1.0.1
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC)

到此这篇关于Linux超详细gcc升级全过程的文章就介绍到这了,更多相关Linux gcc升级内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Linux超详细gcc升级全过程

    目录 前言 1.当前gcc版本 2.安装gcc 3.gmp安装 4.MPFR编译 5.MPC编译 6.GCC 配置 7.GCC版本更新 前言 c c++ 等等 需要这个编译器gcc,最近有DBA的朋友咨询RHEL7.6操作系统安装Mysql数据库时需要 高版本的GCC,研究了下发现坑不少,总结本文分享给大家 1.当前gcc版本 [root@rhel76 ~]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/us

  • linux安装Jenkins超详细全过程

    目录 1 . 安装JDK 2.安装Jenkins 3.修改Jenkins配置 4.启动Jenkins 5.服务器开放端口,打开浏览器访问 6. 获取管理员密码 7. 自定义Jenkins 8. 创建第一个管理员用户 涉及相关 contos7 jdk1.8 jenkins-2.190.3-1.1 1 . 安装JDK #方式一: 小白推荐直接用命令下载 yum install java-1.8.0-openjdk* -y ## 方式二: 下载包官网JDK1.8包: http://www.oracle

  • mysql8.0.23 linux(centos7)安装完整超详细教程

    上篇文章给大家介绍了MySQL 8.0.23 主要更新一览(新特征解读) ,感兴趣的朋友点击查看吧! 最新版windows mysql-8.0.23-winx64,点击下载 mysql8.0.23 linux(centos7)安装教程(附:配置外网连接用户授权 与 不区分大小写配置) (博主在这里叨叨几句,稍后进入正题.在使用开发过程中,有时候数据库结合使用,会成倍提高程序效率) 什么是关系型数据库? 常见的关系型数据库: (其实博主也只使用过 MySQL Oracle sqlServer) O

  • 最新超详细虚拟机VMware安装Kali Linux的图文教程

    准备:一台电脑,VMware(VMware安装教程) 一.下载系统镜像文件 1.首先下载系统镜像,进入kali官网,在Downloads中选择Download Kali Linux,如下图所示. 2.根据电脑配置选择合适的版本,在这里我选择的是64位版本,点击HTTP下载镜像文件. 二.创建新的虚拟机 1.打开VMware Workstation,创建新的虚拟机,我们使用自定义的配置方法. 2.导入系统镜像文件. 3.选择客户机操作系统及版本. 4.输入虚拟机的名称和安装位置. 5.点击下一步直

  • 超详细教你怎么升级Mysql的版本

    一.前言 将mysql5.7 升级为mysql 8.0 准备两个压缩包! 二.备份数据库 1.cmd进入原来数据库中的路径 2.输入命令  mysqldump -u root -p --all-databases > D:\JAVA_Installation\MySQL\data\Backup.sql 1.是你mysql的用户名  平时登录数据库用的用户名 2.保存备份文件的路径 3..sql文件 不要提前建立,它会自动新建. 会进行输入密码,完毕后 备份成功 三.卸载原来的Mysql 111.

  • Linux Samba服务器超详细安装配置(附问题解决)

    目录 Samba服务器介绍 Samba服务器组件 Samba服务器相关的配置文件 安装Samba 第一种方式:yum安装 第二种方式:安装包安装 配置Samba 修改配置文件 添加用户并设置密码 重启Samba服务器 登录Samba 问题汇总及补充 网络选择 防火墙问题 权限问题 无法访问 自动连接 在嵌入式系统开发应用平台中,tftp.nfs和samba服务器是最常用的文件传输工具,tftp和nfs是在嵌入式Linux开发环境中经常使用的传输工具,samba则是Linux和Windows之间的

  • 超详细讲解Linux C++多线程同步的方式

    目录 一.互斥锁 1.互斥锁的初始化 2.互斥锁的相关属性及分类 3,测试加锁函数 二.条件变量 1.条件变量的相关函数 1)初始化的销毁读写锁 2)以写的方式获取锁,以读的方式获取锁,释放读写锁 四.信号量 1)信号量初始化 2)信号量值的加减 3)对信号量进行清理 背景问题:在特定的应用场景下,多线程不进行同步会造成什么问题? 通过多线程模拟多窗口售票为例: #include <iostream> #include<pthread.h> #include<stdio.h&

  • 超详细讲解Linux DHCP服务

    目录 一.DHCP服务(动态主机配置协议) 1.背景 2.概述 3.优点 4.DHCP报文类型 5.DHCP 的分配方式 二.安装 DHCP 服务器 1.DHCP 服务软件 2.主配置文件 三.配置步骤 1.使用 DHCP 动态的给 PC 机分配 IP 地址 ① eNSP ②虚拟机 ③验证 ④进入命令行"ipconfig"测试 一.DHCP服务(动态主机配置协议) 1.背景 1.手动设置工作量大且容易冲突 2.用DHCP可以减少工作量和避免地址冲突 2.概述 作用:为局域网内的电脑分配

  • liunx安装Jenkins超详细全过程

    目录 1 . 安装JDK 2.安装Jenkins 3.修改Jenkins配置 4.启动Jenkins 5.服务器开放端口,打开浏览器访问 6. 获取管理员密码 7. 自定义Jenkins 8. 创建第一个管理员用户 涉及相关 contos7 jdk1.8 jenkins-2.190.3-1.1 1 . 安装JDK #方式一: 小白推荐直接用命令下载 yum install java-1.8.0-openjdk* -y ## 方式二: 下载包官网JDK1.8包: http://www.oracle

  • OneinStack一键安装PHP/JAVA/HHVM和超详细的VPS手动安装LNMP的方法

    继著名的LAMP Stack(Linux + Apache + MySQL/MariaDB + PHP)网站环境之后,LNMP Stack(Linux + Nginx + MySQL/MariaDB + PHP)以其负载小.静态文件处理能力强的优势,在Linux平台上开始流行,尤其是在配置不太高的VPS上应用广泛. 说起LNMP,多数人应该知道lnmp.org站长开发的LNMP一键安装包,该脚本虚拟主机管理.FTP用户管理.Nginx.MySQL/MariaDB.PHP的升级.常用缓存组件的安装

随机推荐