zoukankan      html  css  js  c++  java
  • CentOS下安装高版本GCC


    CentOS下安装高版本GCC 

    微信分享:
     

    有时编译需要用到4.8以上版本的GCC,由于CentOS源没有提供高版本的GCC安装包,这时就不能通过安装包安装。通常的解决方案就是通过编译安装高版本的GCC。

    这里介绍一个更高级、更好用、更简单的方法来升级系统GCC,本文将介绍如何利用CentOS的新特性SCL进行高版本GCC的安装。

    什么是SCL

    请参考:如何在CentOS上启用软件集Software Collections一文

    通过SCL安装GCC

    官方SCL仓库

    devtoolset-3: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-3/

    $ sudo yum install centos-release-scl
    $ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
    $ sudo yum install devtoolset-3
    $ scl enable devtoolset-3 bash

    三方SCL仓库

    copr.fedoraproject.org提供了第三方构建的devtoolset-3/4的仓库, 可直接添加yum源repo后体验devtoolset-3(gcc-4.9.2)、devtoolset-4(gcc-5.2.1)。

    devtoolset-3: https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/
    devtoolset-4: https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/

    devtoolset-3
    • CentOS 6

    安装软件源

    $ wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo   -O /etc/yum.repos.d/rhscl-devtoolset-3-epel-6.repo

    安装devtoolset-3

    $ yum --disablerepo='*' --enablerepo='rhscl-devtoolset-3' list
    $ yum --disablerepo='*' --enablerepo='rhscl-devtoolset-3' install devtoolset-3-gcc devtoolset-3-gcc-c++

    启用SCL环境中新版本GCC

    $ scl enable devtoolset-3 bash

    验证GCC版本

    $ 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.
    • CentOS 7

    安装软件源

    $ wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3-el7/repo/epel-7/rhscl-devtoolset-3-el7-epel-7.repo -O /etc/yum.repos.d/rhscl-devtoolset-3-el7-epel-7.repo

    安装devtoolset-3

    $ yum --disablerepo='*' --enablerepo='rhscl-devtoolset-3-el7' list
    $ yum --disablerepo='*' --enablerepo='rhscl-devtoolset-3-el7' install devtoolset-3-gcc devtoolset-3-gcc-c++

    启用SCL环境中新版本GCC

    $ scl enable devtoolset-3 bash

    验证GCC版本

    $ 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.
    devtoolset-4仓库
    • CentOS 6

    安装软件源

    wget https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-6/hhorak-devtoolset-4-rebuild-bootstrap-epel-6.repo -O /etc/yum.repos.d/hhorak-devtoolset-4-rebuild-bootstrap-epel-6.repo

    安装devtoolset-4

    yum --disablerepo='*' --enablerepo='hhorak-devtoolset-4-rebuild-bootstrap' list
    yum --disablerepo='*' --enablerepo='hhorak-devtoolset-4-rebuild-bootstrap' install devtoolset-4-gcc devtoolset-4-gcc-c++

    启用SCL环境中新版本GCC

    $ scl enable devtoolset-4 bash

    验证GCC版本

    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.
    • CentOS 7

    安装软件源

    wget https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-7/hhorak-devtoolset-4-rebuild-bootstrap-epel-7.repo -O /etc/yum.repos.d/hhorak-devtoolset-4-rebuild-bootstrap-epel-7.repo

    安装devtoolset-4

    yum --disablerepo='*' --enablerepo='hhorak-devtoolset-4-rebuild-bootstrap' list
    yum --disablerepo='*' --enablerepo='hhorak-devtoolset-4-rebuild-bootstrap' install devtoolset-4-gcc devtoolset-4-gcc-c++

    启用SCL环境中新版本GCC

    $ scl enable devtoolset-4 bash

    验证GCC版本

    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.
  • 相关阅读:
    树莓派写Python程序输入不了#
    树莓派系统安装、HDMI显示
    网络七层协议
    TCP协议中的三次握手和四次挥手(图解)(转载http://blog.csdn.net/whuslei/article/details/6667471)
    英语积累
    读《淘宝技术这十年》--笔记
    关于imx6核心板qt系统U盘挂载
    《赢在测试2》-- 推荐的阅读书籍
    三月,关于团队管理的重要性
    自动化测试及工具的一点理解
  • 原文地址:https://www.cnblogs.com/zhming26/p/6691465.html
Copyright © 2011-2022 走看看