[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
:
将该文件上传到虚拟机并开始安装:
[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
提示缺少libmpc
和libmpfr
,只好老老实实地根据提示来继续:
安装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