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. fresco中设置占位/加载失败的图片 无效

    在xml中设置  placeholderImage  属性无效.代码如下: <com.facebook.drawee.view.SimpleDraweeView android:id=" ...

  2. MWeb 的基本使用

    MWeb 的文档库模式和外部模式 MWeb 分为文档库模式和外部模式,下面分别说明. 文档库模式 软件一开始打开就是文档库模式了,开始时需要设置文档库保存的位置,之后所有文档都会保存在这个位置.文档库 ...

  3. 【转】为什么说 Java 程序员必须掌握 Spring Boot ?

    Spring Boot 2.0 的推出又激起了一阵学习 Spring Boot 热,那么, Spring Boot 诞生的背景是什么?Spring 企业又是基于什么样的考虑创建 Spring Boot ...

  4. 如何能够通过代码来重启Android手机?

    String cmd = "su -c reboot";//让手机从启 try { Runtime.getRuntime().exec(cmd); } catch (IOExcep ...

  5. SEMI-PARAMETRIC TOPOLOGICAL MEMORY FOR NAVIGATION

    github: https://github.com/nsavinov/SPTM

  6. 3D Face Reconstruction

    方法1 Large Pose 3D Face Reconstruction from a Single Image via Direct Volumetric CNN Regression http: ...

  7. Linux高级字符设备驱动 poll方法(select多路监控原理与实现)

    1.什么是Poll方法,功能是什么? 2.Select系统调用(功能)      Select系统调用用于多路监控,当没有一个文件满足要求时,select将阻塞调用进程.      int selec ...

  8. 模式识别之检索---Bag of visual word(词袋模型)

    visual words 视觉单词 http://blog.csdn.net/v_july_v/article/details/8203674 http://blog.csdn.net/pi9nc/a ...

  9. 全新升级的WiFi无线上网短信认证系统,适用于咖啡厅、足浴等公共场所,提高门门店营业收入

    WiFi无线上网短信认证系统经历从1.0到1.88的升级,都是用户在使用过程中,提出宝贵的意见,一直修复至今,有着非常稳定的版本. 这个软件有什么作用?WiFi为什么要认证呢? 其实这个只是获取用户联 ...

  10. 单用户模式&救援模式&克隆虚拟机&Linux机器相互登录

    1.13 单用户模式 1.14 救援模式 1.15 克隆虚拟机 1.16 Linux机器相互登录 1.单用户模式 关机:init 0 .poweroff 重启:init 6 .reboot 关机:in ...