因为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. 安卓MVP框架

    一.理解MVP 原文地址 我的Demo 效果图: 项目结构: 实现 一.Model层 首先定义一个实体类User package app.qcu.pmit.cn.mvpdemo.model; /** ...

  2. DP爬台阶问题

    1. 初级爬台阶 - 求最短步数 LC - 70 一次可以迈1-2个台阶,因此最短步数与前两个台阶有关. Initial state: 第一阶:1步 : 第二阶:1步 deduction functi ...

  3. 【Git】【1】简单介绍

    前言: Git:资源管理,版本控制:其实我之前用的是SVN,据说是不好管理分支,不过我做的项目参与人数不多,所以SVN其实是够用的 Git客户端:安转后,可以直接在文件夹进行管理,不需要用命令行形式管 ...

  4. 获取GitHub上远程分支内容

    一.clone项目 二.获取远程特定分支的内容 1.查看所有分支 git branch --all # 默认有了ls和master分支,所以会看到如下三个分支 # master[本地主分支] orig ...

  5. decltype typename

    decltype((variable))总是引用类型,但是decltype(variable)只有当variable是引用类型时才是引用类型. #include <iostream> #i ...

  6. boost高质量随机数库 zhuan

    shared_ptr<int> tmp2(new int(10)) ; int * test=tmp2.get(); std::cout<<*test<<" ...

  7. vue项目目录结构

    VUE项目目录结构 如上图所示,我们的目录结构就是这样的了. 目录/文件 说明 build 这个是我们最终发布的时候会把代码发布在这里,在开发阶段,我们基本不用管. config 配置目录,默认配置没 ...

  8. Guess Number Game

    We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...

  9. 《JavaScript Dom 编程艺术》读书笔记-第9章

    SS-DOM,本章内容: style属性 如何检索样式 如何改变样式三页一体的网页 结构层:由HTML或XHTML之类的标记语言负责创建.标签(tag)也就是尖括号里的单词,对网页内容的语义含义做出了 ...

  10. dyne*cm and N*m