1、安装g++
sudo apt-get install g++
2、报错一:没有这个安装包
解决:换源
①备份,修改源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list
②将sources.list的内容全选替换为以下内容
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
③更新本地源列表
sudo apt-get update
参考链接:
https://blog.csdn.net/qq_36396104/article/details/79748458
⭐如果出现没有以下公钥报错:
解决:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 3B4FE6ACC0B21F32
参考链接:
https://blog.csdn.net/qq_41072096/article/details/104680461
3、报错二:command-not-found has crashed
解决:
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales
参考链接:
https://blog.csdn.net/weixin_34279246/article/details/92472225
4、报错三:Unment dependencies. Try ‘apt-get -f install’ with no packages
解决:
sudo apt-get -f install
sudo apt-get update
sudo apt-get upgrade
sudo apt-get update
sudo apt-get clean
sudo apt-get autoremove
sudo apt --fix-broken install
sudo apt-get update && sudo apt-get upgrade
sudo dpkg --configure -a
sudo apt-get install -f
参考链接:
https://cloud.tencent.com/developer/article/1671540
5、所有错误解决后再执行安装
udo apt-get install g++