当前位置: 首页 > news >正文

(亲测)Centos7升级gcc 9

yum阿里源

备份

# 先备份
sudo cp -r /etc/yum.repos.d /etc/yum.repos.d.bak

下载源文件

cd /etc/yum.repos.d# 下载阿里云 Base 源
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo# 还有其他源可用
# 腾讯源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.cloud.tencent.com/repo/centos7_base.repo# 华为源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo

修改SCLo文件,如果没有可以touch创建后填入下面内容

CentOS-SCLo-scl.repo 文件填入下面内容

# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/7/sclo/$basearch/sclo/
# mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-sclo-testing]
name=CentOS-7 - SCLo sclo Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo Sources
baseurl=http://mirrors.aliyun.com/centos/centos/7/sclo/Source/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-sclo-debuginfo]
name=CentOS-7 - SCLo sclo Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

CentOS-SCLo-scl-rh.repo 文件填入下面内容

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

刷新yum

sudo yum clean all
sudo yum makecache

在这里插入图片描述

手动安装 centos-release-scl

sudo yum install -y centos-release-scl

手动安装 gcc

sudo yum install -y devtoolset-9-gcc devtoolset-9-gcc-c++

在这里插入图片描述

激活gcc

临时方式:

scl enable devtoolset-9 bash
gcc --version

永久方式:

# 备份之前的4.8版本
[root@155 bin]# sudo mv /usr/bin/gcc /usr/bin/gcc4
[root@155 bin]# sudo mv /usr/bin/g++ /usr/bin/g++4# 创建新的符号链接指向 GCC 9.3.1
sudo ln -sf /opt/rh/devtoolset-9/root/usr/bin/gcc /usr/bin/gcc
sudo ln -sf /opt/rh/devtoolset-9/root/usr/bin/g++ /usr/bin/g++

python模块编译配置

因有些python模块安装时需要临时编译,如numpy会报错,还需添加如下环境变量内容

vi /etc/profile# 设置编译器和标志环境变量
export CC=/opt/rh/devtoolset-9/root/usr/bin/gcc
export CXX=/opt/rh/devtoolset-9/root/usr/bin/g++
export CFLAGS='-std=c++17'
export CXXFLAGS='-std=c++17'# 确保 PATH 包含 devtoolset-9 的路径
export PATH="/opt/rh/devtoolset-9/root/usr/bin:$PATH"
http://www.dtcms.com/a/343271.html

相关文章:

  • XTDrone——无人机基于2D激光Lidar进行二维运动规划(细节提醒以及相关报错解决)
  • 嵌入式-中断的概念,优先级,编程-Day17
  • 高效研发管理新选择:Codes 一站式平台深度解析
  • 6.Shell脚本修炼手册---grep命令使用指南
  • 定时器(Timer)和延时器
  • 文化遗产数字化对手持SLAM设备有哪些特殊要求?
  • 使用 X11 转发服务器界面
  • linux安装mysql ndb cluster
  • 牛客:链表分割算法详解
  • Java设计模式-享元模式
  • FreeRTOS学习笔记(三)--汇编指令
  • C ++代码学习笔记(一)
  • Layui 中的 iframe 详解与最佳实践
  • Linux笔记7——shell编程基础-1
  • SMT车间如何通过防静电监控系统提升产品质量
  • 206.反转链表
  • 【时时三省】vectorCAST 便捷使用技巧
  • 利用 Python 爬虫获取淘宝商品评论实战指南
  • 并发编程原理与实战(二十五)手写简易线程池实战,剖析线程状态转换过程
  • 【LINUX网络】UDP协议基础原理
  • Netty AdaptiveRecvByteBufAllocator原理详解
  • 分布式消息队列技术(原理相关):Kafka
  • 机器学习3
  • 《WINDOWS 环境下32位汇编语言程序设计》第6章 定时器和Windows时间
  • Git 版本控制核心流程与协作指南(从入门到冲突解决)
  • windows下jdk环境切换为jdk17后,临时需要jdk1.8的处理
  • 机器学习笔试题
  • 如何利用淘宝API接口实现自动下单?实战案例讲解
  • 【无标题】GAP: 用文本指导对任何点云进行高斯化(ICCV 2025)
  • 香港云服务器被暴力破解的危害有多大?