zoukankan      html  css  js  c++  java
  • gcc centos 新版本的安装方法

    因为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

  • 相关阅读:
    页面跳转刷新
    表格表头绘制对角线(不固定表格宽高)
    发送邮件的工具类
    重写equals()和hashCode()
    设计模式--原型模式[转载]
    设计模式--外观模式
    设计模式--代理模式
    js处理json js递归
    MySQL锁详解
    开发一个微信小程序实例教程
  • 原文地址:https://www.cnblogs.com/si812cn/p/10043195.html
Copyright © 2011-2022 走看看