栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Ubuntu高版本如何安装低版本GCC

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Ubuntu高版本如何安装低版本GCC

Ubuntu高版本如何安装低版本GCC

以Ubuntu 20安装GCC5为例

如果想用低版本的gcc,比如gcc5,尝试输入命令
sudo apt-get install gcc-5
会提示找不到gcc5的安装包
那么就需要添加较低版本的源
网上搜索得到gcc5对应的Ubuntu版本为16,接下来就对Ubuntu20.04的源文件source.list进行编辑,增加Ubuntu16的源

通过命令用gedit编辑器(也选择其他编辑器,如vim,mousepad等)打开source.list文件,
sudo gedit /etc/apt/sources.list
在文件尾部增加Ubuntu16的源,我使用的是阿里云的源

# ubuntu 16
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
 
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
 
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe

保存文件后,输入命令,更新源

sudo apt-get update

然后输入命令,查看gcc5可选的版本

apt-cache policy gcc-5

安装gcc-5 g+±5

sudo apt-get install gcc-5 g++-5

或者
选择其中一个版本进行安装

sudo apt-get install gcc-5=5.4.0-6ubuntu1~16.04.12
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/511702.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号