Linux(CentOs7)安装gcc编译器

背景

提供在线、离线安装方式

在线安装

网络允许的情况下在线安装,方便省事,但在公司内网环境,无法联网的情况下,需要进行离线安装

# 安装gcc、gcc的c++编译器以及内核文件
yum -y install gcc gcc-c++ kernel-devel 

离线安装

准备材料

gcc相关rmp安装包

获取方式

方式1: 官网自行下载
方式2: 解压CentOs7的镜像包,在 Packages目录 中获取,镜像包需要是DVD版本,如果是 Minimal 版本,很多rmp包是没有的,比如我这里的镜像包版本是 CentOS-7-x86_64-DVD-1511.iso
在这里插入图片描述

挑选gcc需要的安装包

cpp-4.8.5-4.el7.x86_64.rpm
gcc-4.8.5-4.el7.x86_64.rpm
glibc-devel-2.17-105.el7.x86_64.rpm
glibc-headers-2.17-105.el7.x86_64.rpm
kernel-headers-3.10.0-327.el7.x86_64.rpm
libmpc-1.0.1-3.el7.x86_64.rpm
mpfr-3.1.1-4.el7.x86_64.rpm

上传到服务器指定目录

我是上传到 /root/gcc 目录
在这里插入图片描述

安装gcc

挨个安装

rmp -ivh cpp-4.8.5-4.el7.x86_64.rpm
rmp -ivh gcc-4.8.5-4.el7.x86_64.rpm
rmp -ivh glibc-devel-2.17-105.el7.x86_64.rpm
rmp -ivh glibc-headers-2.17-105.el7.x86_64.rpm
rmp -ivh kernel-headers-3.10.0-327.el7.x86_64.rpm
rmp -ivh libmpc-1.0.1-3.el7.x86_64.rpm
rmp -ivh mpfr-3.1.1-4.el7.x86_64.rpm
[root@localhost gcc]# rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:mpfr-3.1.1-4.el7                 ################################# [100%]
[root@localhost gcc]# 

或者统一命令安装(推荐)

[root@localhost gcc]# rpm -Uvh *.rpm --nodeps --force
准备中...                          ################################# [100%]
正在升级/安装...
   1:mpfr-3.1.1-4.el7                 ################################# [ 14%]
   2:libmpc-1.0.1-3.el7               ################################# [ 29%]
   3:cpp-4.8.5-4.el7                  ################################# [ 43%]
   4:kernel-headers-3.10.0-327.el7    ################################# [ 57%]
   5:glibc-headers-2.17-105.el7       ################################# [ 71%]
   6:glibc-devel-2.17-105.el7         ################################# [ 86%]
   7:gcc-4.8.5-4.el7                  ################################# [100%]

验证安装结果

[root@localhost gcc]# gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
目标:x86_64-redhat-linux
配置为:../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
线程模型:posix
gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC) 
  • 5
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值