因为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. webpack简单修改版本号(单页面)

    写了一个js文件,可以尽量最简单的修改版本号 package.json配置: updateV.js放置位置: updateV.js: var fs = require('fs'); //文件读写 va ...

  2. spring El

    package com.wisely.heighlight_spring4.ch2.el; import java.io.IOException; import org.apache.commons. ...

  3. 另一道不知道哪里来的FFT题

    给定一个序列,求出这个序列的k阶前缀和,模998244353,n<=1e5. k阶前缀和可以看成一个一个n*k的平面上的二维行走问题. 第i项对第j项的贡献是从(i,0)走到(j,k)的NE L ...

  4. jQuery.ready() 函数详解

    jQuery.ready() 函数详解 ready()函数用于在当前文档结构载入完毕后立即执行指定的函数. 该函数的作用相当于window.onload事件. 你可以多次调用该函数,从而绑定多个函数, ...

  5. linux-Centos7安装python3并与python2共存

    1.查看是否已经安装Python CentOS 7.2 默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用 python -V 命令查看一下是否安 ...

  6. 人群密度估计 CrowdCount

    最近在看人群密度估计方面的东西,把博客看到的一些方法简单总结一下,后续继续添加. 1.论文<CrowdNet: A Deep Convolutional Network for DenseCro ...

  7. FCC JS基础算法题(3):Find the Longest Word in a String (找出最长单词)

    题目描述: 在句子中找出最长的单词,并返回它的长度.函数的返回值应该是一个数字. 基本思路,将字符串转换成数组,然后得出数组中单个元素的长度,对长度进行排序,返回最大的一个 代码: function ...

  8. 蘑菇街支付架构 PDF 下载

    蘑菇街支付架构 PDF 下载 下载地址:链接:https://pan.baidu.com/s/1ZffetaUhVMOzb9j2PSQJIQ 密码:iays http://www.java1234.c ...

  9. django 问题总结

    1.更新了pip之后还提示更新 // 卸载 pip uninstall pip // 重新安装 easy_install pip pip -V 2.时间比当前时间少8小时问题 // 设置setting ...

  10. testDecoration

    def count(): fs = [] for i in range(1,4): def f(): n=i*i return n fs.append(f) return fs c1,c2,c3 = ...