[GCC] CentOS下离线升级gcc

CentOS7离线升级gcc

最近的工作中,需要将测试服务器上的gcc升级到8.3+,但苦于无法连接外网,因此只能寻求离线安装的方式。在此记录一下安装过程中的收获(以下是在自己虚拟机上的操作)。操作系统版本:

[root@localhost ~]# 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.8.2003 (Core)
Release:	7.8.2003
Codename:	Core

在此记录一下,lsb_release命令需要安装redhat-lsb.x86_64,需要通过yum search lsb来查找安装包:

[root@localhost ~]# yum search lsb
redhat-lsb.x86_64 : Implementation of Linux Standard Base specification

以下操作在无外网连接的情况下进行。

安装gcc

首先,查看本机的gcc版本:

[root@localhost ~]# gcc -v
-bash: gcc: command not found

以上提示说明本机没有安装gcc。怎么办?坑还是得慢慢踩平的。(本节的第1小节为踩坑过程,第2小节为具体的安装步骤,请移步至第2小节:gcc安装小结

踩坑过程记录

想起了之前下载的CentOS镜像文件:CentOS-7-x86_64-DVD-1810.iso*(下载地址:http://isoredirect.centos.org/centos/7/isos/x86_64/),里面应该能找到gcc的安装包。果然,对该镜像文件进行解压后,在Packages下找到了gcc
解压iso镜像文件
gccrpm
将该文件上传到虚拟机并开始安装:

[root@localhost gcc]# rpm -ivh gcc-4.8.5-36.el7.x86_64.rpm 
error: Failed dependencies:
	cpp = 4.8.5-36.el7 is needed by gcc-4.8.5-36.el7.x86_64
	glibc-devel >= 2.2.90-12 is needed by gcc-4.8.5-36.el7.x86_6
	libgomp = 4.8.5-36.el7 is needed by gcc-4.8.5-36.el7.x86_64
	libmpc.so.3()(64bit) is needed by gcc-4.8.5-36.el7.x86_64
	libmpfr.so.4()(64bit) is needed by gcc-4.8.5-36.el7.x86_64

提示缺少相关依赖,这些依赖都能在Packages文件夹下找到。
对应关系如下:

cpp:cpp
libgomp:libgomp
libmpc:libmpc
libmpfr:mpfr

依次安装各依赖:

安装cpp
[root@localhost gcc]# rpm -ivh cpp-4.8.5-36.el7.x86_64.rpm 
error: Failed dependencies:
	libmpc.so.3()(64bit) is needed by cpp-4.8.5-36.el7.x86_64
	libmpfr.so.4()(64bit) is needed by cpp-4.8.5-36.el7.x86_64

提示缺少libmpclibmpfr,只好老老实实地根据提示来继续:

安装libmpc
[root@localhost gcc]# rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm 
error: Failed dependencies:
	libmpfr.so.4()(64bit) is needed by libmpc-1.0.1-3.el7.x86_64

好吧……看来在最后的才是最底层的依赖……

安装mpfr
[root@localhost gcc]# rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:mpfr-3.1.1-4.el7                 ################################# [100%]

mpfr安装成功,继续尝试安装mpc

[root@localhost gcc]# rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:libmpc-1.0.1-3.el7               
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值