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. android尺子的自定义view——RulerView

    项目中用到自定义尺子的样式: 原代码在github上找的,地址:https://github.com/QQabby/HorizontalRuler 原效果为 因为跟自己要使用的view稍有不同  所以 ...

  2. 慎用 apt-get autoremove !

    apt-get 提供了一个用于下载和安装软件包的简易命令行界面. 卸载软件包主要有这3个命令 remove – 卸载软件包 autoremove – 卸载所有自动安装且不再使用的软件包 purge – ...

  3. e789. 限制用JSpinner实现数字选择的值

    // Create a number spinner that only handles values in the range [0,100] int min = 0; int max = 100; ...

  4. python写的读取json配置文件

    配置文件默认为conf.json 使用函数set完成追回配置项. 使用load或取配置项. 代码如下: #!/usr/bin/env python3 # -*- coding: utf-8 -*- ' ...

  5. CI框架 -- 核心文件 之 Output.php(输出类文件)

    CI输出类Output.php的功能是将最终web页面发送给浏览器,这里面的东西可能是你用的最少的.你使用装载器加载了一个视图文件, 这个视图文件的内容会自动传递给输出类对象, 然后呢,在方法执行完毕 ...

  6. 浅谈android中只使用一个TextView实现高仿京东,淘宝各种倒计时

    今天给大家带来的是只使用一个TextView实现一个高仿京东.淘宝.唯品会等各种电商APP的活动倒计时.近期公司一直加班也没来得及时间去整理,今天难得歇息想把这个分享给大家.只求共同学习,以及自己兴许 ...

  7. Lemon OA第4篇:常用功能

    OA,Office Automation的简写,中文意思办公自动化,不同的人有不同的见解,可以简单的理解为网络化办公,高效.协同是其显著的特点,如今正在朝着智能的方向发展 平时不擅长文字,写出来几句话 ...

  8. LigerUI树节点选中之后节点背景太短

    LigerUI树节点选中之后的效果如下: 可以看出,节点的背景太短,不能适应树的宽度 理想的效果应该是节点选中之后,节点背景和树的宽度一样 虽然没有找到官方的解决办法 但是,通过查询LigerUI的A ...

  9. Java Number类

    一般地,当需要使用数字的时候,我们通常使用内置数据类型,如:byte.int.long.double等. 例如: int i = 5000; float gpa = 13.65; byte mask ...

  10. Vue 404页面处理

    问题原因: 刷新页面时访问的资源在服务端找不到,因为vue-router设置的路径不是真实存在的路径 解决方案: 第一步:后端配置 Apache <IfModule mod_rewrite.c& ...