ubuntu安装GCC报错(gcc : 依赖: cpp (= 4:9.3.0-1ubuntu2) 但是 4:11.2.0-1ubuntu1 等等一连串)

我参考了以下两个链接尝试成功总结的,感谢!:

https://blog.csdn.net/qq_41286751/article/details/125540832?spm=1001.2014.3001.5502

https://blog.csdn.net/qq_41286751/article/details/125557165?spm=1001.2014.3001.5506

原因:Ubuntu镜像源不对

确保换的源,跟安装的Ubuntu系统版本匹配!

比如ubuntu22.04应该换jammy源,其他的版本还有focal源等。

通过查看系统版本命令可以看到:

lsb_release -a

查看到版本后就可以开始换源

1.备份系统的源(略)

2.使用gedit编辑文件换源

代码如下:

sudo gedit /etc/apt/sources.list

2.然后从网上找相应的源(阿里源,清华源等)

注意看源中的是focal、bionic等。

3.换源(jammy为例,其他的网上找)

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
 

复制上述代码到sources文件中去。
执行下面两个命令:

sudo apt-get update
#这个命令,会访问源列表里的每个网址,并读取软件列表,然后保存在本地电脑。我们在新立得软件包管理器里看到的软件列表,都是通过update命令更新的。

sudo apt-get upgrade
#这个命令,会把本地已安装的软件,与刚下载的软件列表里对应软件进行对比,如果发现已安装的软件版本太低,就会提示你更新。如果你的软件都是最新版本,会提示:
#升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。

没有报错就行了,正常安装gcc等。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值