CentOS 7.5下在线yum安装GCC与G++

2020-09-11 0 530 百度已收录

GCC(GNU Compiler Collection)是Linux下最主要的编译工具,GCC不仅功能非常强大,结构也非常灵活。它可以通过不同的前端模块来支持各种语言,如Java、Fortran、Pascal、Modula-3和Ada。

在CentOS下,可以在联网状态在线yum安装GCC,但是此种方式安装的GCC是4.8.5版本的,有时候已经不能满足需要。因此还需在此基础上进行升级。截止目前已经有5.0以上的最新版本了,GCC 4.8 开始全面支持C 11和C++ 11的新特性。

先查看下CentOS系统有没有安装GCC与G++。

打开终端输入gcc -v或者:g++ -v

CentOS 7.5下在线yum安装GCC与G++

显示没有安装,下面开始安装。

使用yum安装gcc与g++

在有网络连接条件下进行分别执行如下命令

#安装gcc、c++编译器以及内核文件

[linuxidc@localhost linuxidc.com]$ sudo yum -y install gcc gcc-c++ kernel-devel

输出:

已安装:
  gcc.x86_64 0:4.8.5-28.el7_5.1              gcc-c++.x86_64 0:4.8.5-28.el7_5.1
  kernel-devel.x86_64 0:3.10.0-862.14.4.el7

作为依赖被安装:
  glibc-devel.x86_64 0:2.17-222.el7                                           
  glibc-headers.x86_64 0:2.17-222.el7                                         
  kernel-headers.x86_64 0:3.10.0-862.14.4.el7                                 
  libstdc++-devel.x86_64 0:4.8.5-28.el7_5.1                                   

作为依赖被升级:
  cpp.x86_64 0:4.8.5-28.el7_5.1        libgcc.x86_64 0:4.8.5-28.el7_5.1     
  libgomp.x86_64 0:4.8.5-28.el7_5.1    libstdc++.x86_64 0:4.8.5-28.el7_5.1   

完毕!

CentOS 7.5下在线yum安装GCC与G++

#如果没有安装make:

yum install make

查看下,默认已经安装好了。

[linuxidc@localhost linuxidc.com]$ make -v
GNU Make 3.82
Built for x86_64-RedHat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

CentOS 7.5下在线yum安装GCC与G++

#验证安装成功的方法

[linuxidc@localhost linuxidc.com]$ 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-28) (GCC)

CentOS 7.5下在线yum安装GCC与G++

或者:

[linuxidc@localhost linuxidc.com]$ g++ -v
使用内建 specs。
COLLECT_GCC=g++
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-28) (GCC)

CentOS 7.5下在线yum安装GCC与G++

如果显示的gcc版本仍是以前的版本,可以重启系统; 

#查看gcc的安装位置:which gcc;

[linuxidc@localhost linuxidc.com]$ which gcc
/usr/bin/gcc

CentOS 7.5下在线yum安装GCC与G++

测试一个C程序

#include<stdio.h>

int main()
{
printf(“nLinux公社(www.linuxidc.com)是专业的Linux系统门户网站nn”);
return 0;
}

CentOS 7.5下在线yum安装GCC与G++

OK。

在线安装这里没有对gmp、mpfr、mpc等软件分别进行解压和编译,而是直接由download_prerequisites负责下载并解压,最后和gcc一起进行编译安装,这是官方推荐的做法。

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

栗子博客 软件 CentOS 7.5下在线yum安装GCC与G++ https://www.lizi.tw/soft/12037.html

常见问题
  • 1、杰齐1.7仅适用于PHP5.2 2、需Zend支持 3、尽量使用宝塔面板 4、尽量使用Windows 系统,关关对Linux支持不太友好。
查看详情

相关文章

评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

CentOS 7.5下在线yum安装GCC与G++-海报

分享本文封面