一.更换镜像源
仅仅针对有需要换镜像需求的用户
sudo gedit /etc/apt/sources.list 用于在基于Debian的Linux发行版(如Ubuntu)上用来编辑软件源列表的命令。
我们更换阿里源:
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
sudo apt update
sudo apt upgrade以此来更新镜像源
二.安装更新gcc版本
搭建了镜像源后,用该sudo apt install gcc-8 g+±8命令下载gcc需要的版本,我这里下载的gcc-8
下载gcc相应版本后,需要添加到备选项
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g+±8
三.手动配置gcc和g++版本
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
用于手动配置gcc和g++版本
用gcc --version和g++ --version查看刚才应用的gcc版本,说明安装gcc成功