centos7中根据gcc编译器安装包升级gcc编译器

发布时间 2023-07-17 12:06:37作者: 小鲨鱼2018

 

001、系统信息

[root@PC1 home]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core)
Release:        7.6.1810
Codename:       Core

 

002、当前gcc版本

[root@PC1 home]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 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.

 

003、安装升级依赖

[root@PC1 home]# yum install -y gcc-c++ glibc-devel mpfr-devel libmpc-devel gmp-devel glibc-devel.i686

 

004、下载安装包

[root@PC1 software]# wget -c https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.gz --no-check-certificate

 

005、解压安装包

[root@PC1 software]# tar -xzvf gcc-13.1.0.tar.gz
[root@PC1 software]# cd gcc-13.1.0/

 

006、下载依赖包

[root@PC1 gcc-13.1.0]# ./contrib/download_prerequisites

 

007、创建build目录

[root@PC1 gcc-13.1.0]# mkdir build
[root@PC1 gcc-13.1.0]# cd build/

 

008、安装到指定目录(说明:若安装到非/usr目录,如安装到/opt/gcc,则在编译完成后需要配置环境变量、建立软连接。)

[root@PC1 build]# ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr

 

009、编译安装