WSL:Windows10下Linux子系统Ubuntu安装g++失败问题

背景

上午小伙伴因为安装gcc,g++等编译器问题遇到失败,最终查到找原因为apt源问题,记录下。

办法

WSL默认是Ubuntu的官方源,国内连接也比较慢,现在更改为aliyun源

1.备份

sudo  mv /etc/apt/sources.list /etc/apt/sources.list.bak

2.准备源

#aliyun 
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

3.替换

# 1
sudo vim /etc/apt/sources.list
# 2
插入上面2的aliyun apt源
# 3
退出、保存

4.更新

# 1
sudo apt update
# 2
sudo apt upgrade

5.安装

# 愉快的安装吧
apt install gcc g++ -y

你可能感兴趣的:(知识库)