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.

CentOS下安装高版本GCC的更多相关文章

  1. CentOS7安装高版本gcc

    CentOS7安装高版本gcc 下载 从hust镜像站下载gcc源码包. http://mirror.hust.edu.cn/gnu/gcc/ 我选择的是gcc-8.3.0.tar.gz. cd mk ...

  2. centos下安装最新版本git(通过master分支下载最新版)

    centos6.7下安装最新版本git 本文参考:http://www.01happy.com/centos-install-latest-git/ 按照原博主所提供的思路安装可能会出现下列问题 解决 ...

  3. CentOS7 安装高版本gcc, g++, gfortran等工具

    SCL(Software Collections)是一个CentOS/RHEL Linux平台的软件多版本共存解决方案,为用户提供一种方便.安全地安装和使用应用程序和运行时环境的多个版本的方式. De ...

  4. Ubantu 14.04下安装高版本cmake

    Ubantu14.04 下自带的cmake版本比较低(默认为2.8),这里我们从源码编译高版本cmake: 先卸载电脑上安装的cmake (如何已安装的话): sudo apt-get autorem ...

  5. ubuntu下安装低级版本gcc/g++ 并随意切换

    来自:http://blog.sina.com.cn/s/blog_6cee149d010129bl.html 发现Android的版本中编译Host的程序经常因为本机的Gcc版本过高,需要这样那样的 ...

  6. Centos下安装最新版本Git

    git是一个分布式版本控制系统 我们在Centos上安装GIT有好几种方式.这里我们用最简单的yum命令方式 一步到位,省了下载编译安装这些繁琐过程. 输入命令: yum install -y git ...

  7. centos yum安装高版本php,apache,mysql

    1.检查当前安装的PHP包 yum list installed | grep php 或者   yum list installed php* 如果要删除,可执行 yum remove php.x8 ...

  8. Centos6下安装高版本Git

    yum remove git .tar.gz /usr/src/ cd /usr/src/ cd git-/ make configure whereis autoconf yum install a ...

  9. centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'

    centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named '_ctypes'的解决办法 3.7版本需要一个新的包libffi-de ...

随机推荐

  1. PCL中可用的PointT类型

    PCL中可用的PointT类型: PointXYZ——成员变量:float x,y,z; PointXYZ是使用最常见的一个点数据类型,因为他之包含三维XYZ坐标信息,这三个浮点数附加一个浮点数来满足 ...

  2. 最近玩Bootstrap , 一些小工具 记录在案。

    最近玩Bootstrap , 一些小工具 记录在案. 1 定制Bootstrap ,所见即所得的修改Bootstrap的各种变量,即时查看样式的变化. http://bootswatchr.com/ ...

  3. etl的表输入时精度问题

    SELECT RecipeID, IngredientID as ingre_id, ROUND(Quantity, 5) Quantity, Preparation, RecipeIngredien ...

  4. 17个CSS知识点整理

    1.对WEB标准以及W3C的理解与认识 标签闭合.标签小写.不乱嵌套.提高搜索机器人搜索几率:使用外链css和js脚本.结构行为表现的分离.文件下载与页面速度更快:内容能被更多的用户所访问.内容能被更 ...

  5. QT:QObject 简单介绍

    QObject 是所有Qt对象的基类. QObject 是Qt模块的核心.它的最主要特征是关于对象间无缝通信的机制:信号与槽.使用connect()建立信号到槽的连接,使用disconnect()销毁 ...

  6. 摄像头驱动OV7725学习笔记连载(一):OV7725 电器特性和时序图

    OV(豪威科技)已经被中国财团收购.这个昔日的大佬,最终走下神坛. 关于OVsensor的资料包括,OV7725的简介(OmniVsion_OV7725),OV7725的数据手册(OV7725_Dat ...

  7. SSH-简单登陆业务详解,从环境部署到代码编写

    一直都是半解半知的情况下动手去实现某些功能,但是竟然也可以成功, 而我发现你花2小时听视频看所谓的理论,不如花2小时直接做个功能出来, 更加深了对此框架的理解,中间遇到问题后,可以上网再查详细的知识点 ...

  8. Mybatis trim标签

      trim代替where/set标签 trim 是更灵活用来去处多余关键字的标签,它可以用来实现 where 和 set 的效果. <!-- 使用 if/trim 代替 where(判断参数) ...

  9. (转)编译android5.1,添加swap分区的方法

    clang++: error: unable to execute command: Killedclang++: error: assembler command failed due to sig ...

  10. 系统中hosts文件有哪些作用

    hosts文件位于系统盘C:\Windows\System32\drivers\etc中,hosts是一个没有扩展名的系统文件,其基本作用就是将一些常用的网址域名与其对应的IP地址建立一个关联“数据库 ...