Ubuntu 14.04通过sudo apt-get install g++ 出现“g++: Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to beinstalled”错误。
是因为ubuntu14.04的源过旧或不可访问导致,可以通过更新源解决。
首先,备份原始源文件source.list
sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup
其次,依据ubuntu的版本添加新的源
1)lsb_release-a查看ubuntu版本号
比如No LSB modules are available.
Distributor ID:Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename:trusty
2)依据版本号如14.04trusty选择新的源文件,并添加到/etc/apt/source.list文件尾部
选择Ubuntu官方更新服务器(欧洲,此为官方源,国内较慢,但无同步延迟问题,电信、移动/铁通、联通等公网用户可以使用):
deb http://archive.ubuntu.com/ubuntu/ trusty main restricteduniverse multiverse
deb http://archive.ubuntu.com/ubuntu/trusty-security main restricted universe multiverse
debhttp://archive.ubuntu.com/ubuntu/ trusty-updates main restricteduniverse multiverse
deb http://archive.ubuntu.com/ubuntu/trusty-proposed main restricted universe multiverse
debhttp://archive.ubuntu.com/ubuntu/ trusty-backports main restricteduniverse multiverse
deb-src http://archive.ubuntu.com/ubuntu/trusty main restricted universe multiverse
deb-srchttp://archive.ubuntu.com/ubuntu/ trusty-security main restricteduniverse multiverse
deb-src http://archive.ubuntu.com/ubuntu/trusty-updates main restricted universe multiverse
deb-srchttp://archive.ubuntu.com/ubuntu/ trusty-proposed main restricteduniverse multiverse
deb-src http://archive.ubuntu.com/ubuntu/trusty-backports main restricted universe multiverse
并将这些源添加到/etc/apt/source.list文件末尾
3)更新ubuntu源
sudo apt-get update
虽然这时还能看到部分源的包不能下载,但没关系,系统会自动的从新添加的源下载。