因为centos默认安装的gcc是GCC 4.*.* 是不支持 C++11 的,所以有些新的程序或软件要安装就行要升级GCC,否则无法编译通过

一、如下步骤安装不成功(yum install devtoolset-4),基本上是因为仓库不提供相应版本,请先执行yum search devtoolset查询一下

gcc 4.8 安装

01
02
03
04
05
06
07
08
09
10
11
12
13
[root@DS-VM-Node239 ~]# curl -Lks http://www.hop5.in/yum/el6/hop5.repo > /etc/yum.repos.d/hop5.repo
[root@DS-VM-Node239 ~]# yum install gcc gcc-g++ -y
[root@DS-VM-Node239 ~]# gcc --version
gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-8)
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
[root@DS-VM-Node239 ~]# g++ --version
g++ (GCC) 4.8.2 20131212 (Red Hat 4.8.2-8)
Copyright © 2013 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。
[root@DS-VM-Node211 ~]#

gcc 4.9 安装

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@DS-VM-Node239 ~]# yum install centos-release-scl -y
[root@DS-VM-Node239 ~]# yum install devtoolset-3-toolchain -y
[root@DS-VM-Node239 ~]# scl enable devtoolset-3 bash
[root@DS-VM-Node239 ~]# gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 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.
 
[root@DS-VM-Node239 ~]# g++ --version
g++ (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 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.
 
[root@DS-VM-Node239 ~]# gfortran --version
GNU Fortran (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
Copyright (C) 2014 Free Software Foundation, Inc.
 
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
 
[root@DS-VM-Node239 ~]#

gcc 5.2 安装

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
[root@DS-VM-Node239 ~]# yum install centos-release-scl -y
[root@DS-VM-Node239 ~]# yum install devtoolset-4-toolchain -y
[root@DS-VM-Node239 ~]# scl enable devtoolset-4 bash
[root@DS-VM-Node239 ~]# gcc --version
gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)
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.
 
[root@DS-VM-Node239 ~]# g++ --version
g++ (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)
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.
 
[root@DS-VM-Node239 ~]#

二、使用新的办法

yum -y install centos-release-scl-rh centos-release-scl

参考 https://linux.cn/article-8509-1.html?utm_source=weibo&utm_medium=weibo

三、重新指向国内的源头

参考 https://blog.csdn.net/tao_627/article/details/77260963

四、添加源并安装

rpm --import http://linuxsoft.cern.ch/cern/slc68/x86_64/RPM-GPG-KEY-cern \
 wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo \
yum search devtoolset

参考 https://www.aliyun.com/jiaocheng/1389684.html

gcc centos 新版本的安装方法的更多相关文章

  1. centos的软件安装方法rpm和yum

    centos的软件安装大致可以分为两种类型: [centos]rpm文件安装,使用rpm指令  类似[ubuntu]deb文件安装,使用dpkg指令 [centos]yum安装   类似[ubuntu ...

  2. 压力测试工具ab及centos下单独安装方法 nginx和tomcat静态资源的性能测试

    Apache安装包中自带的压力测试工具Apache Benchmark(简称ab)简单易用,这里采用ab作为压国测试工具. 独立安装: ab运行需要信赖apr-util包: # yum install ...

  3. centos 较新版本kernel安装方法

    有时因为系统内核的bug 我们必须要安装新版本的kernel 来解决问题,有几种方法 源码编译 使用编译好的包 使用包的方式比较方便,同时一些依赖的问题可以自动帮助我们处理 添加yum 源 rpm - ...

  4. Centos 7 GCC 7.3编译器安装方法及C++17标准测试示例

    1.下载gcc-7.3.0源码 http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-7.3.0/ 2.下载编译依赖 [root@localhost ~] ...

  5. CentOS常用软件安装方法

    软件包介绍 源码包(脚本安装包) 二进制包(RPM包,系统默认包) 源码包 优点 开源,如果有足够的能力,可以修改源代码 编译安装,更加适合自己的系统,稳定高效 缺点 安装步骤较多,容易出错 编译过程 ...

  6. 压力测试工具ab及centos下单独安装方法

    压力测试工具Ab简介 Apache安装包中自带的压力测试工具 Apache Benchmark(简称ab) 简单易用,这里就采用 ab作为压力测试工具了. 1.独立安装 ab运行需要依赖apr-uti ...

  7. CentOS使用epel安装不同版本php-fpm

    针对CentOS使用epel安装 yum -y install epel-release安装好后可以通过如下命令查看yum info epel-releaseyum repolist查看php版本ph ...

  8. 在CentOS 7上安装Node.js的4种方法(yum安装和源码安装)

    CentOS 7上的安装方法,其中涵盖了源码安装,已编译版本安装,EPEL(Extra Packages for Enterprise Linux)安装和通过NVM(Node version mana ...

  9. 在CentOS 7上安装Node.js的4种方法(包含npm)

    Node.js和Javascript有着千丝万缕的联系,可以说Node.js让Javascript显得从未如此强大.好吧…微魔其实是个门外汉…但是这并不能阻碍微魔学习探索未知的信心~今天在国外闲逛,看 ...

随机推荐

  1. 基于Bootsrap的BeyondAdmin前端模板 --分享

    1.PC端 2.移动端 3.下载 最新:http://www.yidt.cn/ 链接:https://pan.baidu.com/s/1Tx6EVmGFnVV7H7h3SFwldA 提取码:0btw

  2. html5画心

     

  3. js中的object

    JavaScript is an object-based language based on prototypes, rather than being class-based. this引用对象 ...

  4. Linq(一)

    概述 LINQ是.NET框架的扩展,它允许我们以使用SQL查询数据库的方式来查询数据集合. 使用LINQ,你可以从数据库.程序对象集合以及XML文档中查询数据. 需要注意的是,对于比较简单的功能,与其 ...

  5. learning makefile = and :=

  6. VirtualBox fedora29 安装

    目录 准备工作 VirtualBox安装 fedora安装 快捷键定义 准备工作 平台配置 win10 64位 内存 8G 硬盘 1T 下载地址 VirtualBox 5.2.22:https://w ...

  7. maven win 安装 与 IntelliJ IDEA 配置Maven【2018-11-14最新最有姿势攻略】

    [博客园cnblogs笔者m-yb原创,转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708] http ...

  8. GeoServer java.io.IOException: No such resource: generic.sld No such resource: generic.sld

    原因是 发布 图层时 没有设置类型 默认 generic 但是我们的数据库中 没有这个 解决办法: 点击 图层--点击 相应的 图层名称 ---发布  --- WMS Settings 下面的Defa ...

  9. <zk在大型分布式系统中的应用>

    Hadoop 在hadoop中,zk主要用来实现HA(High Availability).这部分逻辑主要集中在hadoop common的HA模块中,HDFS的NameNode和Yarn的Resou ...

  10. 剑指Offer 45. 扑克牌顺子 (其他)

    题目描述 LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^)...他随机从中抽出了5张牌,想测测自己的手气,看看能不能抽到顺子,如果抽到的话,他决 ...