Ubuntu20.04换阿里源(解决安装build-essential失败问题)
2021/12/12 7:18:47
本文主要是介绍Ubuntu20.04换阿里源(解决安装build-essential失败问题),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
背景:
在Ubuntu20.04 LTS上,需要使用gcc和g++编译器编译程序,在安装build-essential时报错。如下:
acl@ubuntu:~/test$ sudo apt install build-essential Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: build-essential : Depends: libc6-dev but it is not going to be installed or libc-dev Depends: g++ (>= 4:7.2) but it is not going to be installed Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
初步猜测是源的问题,因此将源换成阿里的源,具体步骤如下:
1 备份原来的源
cp -ra /etc/apt/sources.list /etc/apt/sources.list.bak
2 将源换成阿里源
sudo gedit /etc/apt/sources.list
然后将里面的内容清空,把下面的内容复制进去,保存退出:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
3 更新缓存和升级
sudo apt-get update sudo apt-get upgrade
此时阿里源已经换好。
再次安装build-essential,就会发现能安装成功了。
测试gcc和g++是否安装成功:
gcc -v g++ -v
这篇关于Ubuntu20.04换阿里源(解决安装build-essential失败问题)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-21订单系统资料入门教程:轻松管理你的订单
- 2024-09-21Java部署资料:新手入门教程
- 2024-09-21Java部署资料:新手入门教程
- 2024-09-21Java订单系统资料:新手入门教程与实战指南
- 2024-09-21Java管理系统资料入门教程
- 2024-09-21从零开始学习Java监控系统资料
- 2024-09-21Java就业项目资料:新手入门的必备教程
- 2024-09-21Java全端资料:初学者指南
- 2024-09-21Java全栈资料入门教程及资源汇总
- 2024-09-21Java日志系统资料入门教程