红联Linux门户
Linux帮助

ubuntu 14.04 install g++问题"g++:Depends:g++-4.8(>= 4.8.2-5

发布时间:2015-11-05 10:36:09来源:linux网站作者:liliang199

Ubuntu 14.04通过 sudo apt-get install g++ 出现“g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed”错误。

是因为ubuntu 14.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.04 trusty选择新的源文件,并添加到/etc/apt/source.list文件尾部

例如,我参考

http://chenrongya.blog.163.com/blog/static/8747419620143185103297/

和 http://wiki.ubuntu.org.cn/Template:14.04source,

选择Ubuntu 官方更新服务器(欧洲,此为官方源,国内较慢,但无同步延迟问题,电信、移动/铁通、联通等公网用户可以使用):

deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

并将这些源添加到/etc/apt/source.list文件末尾


3)更新ubuntu 源

sudo apt-get update

虽然这时还能看到部分源的包不能下载,但没关系,系统会自动的从新添加的源下载。


4)这时再次运行sudo apt-get install g++就能正常安装了。


Linux下gcc与g++的差别:http://www.linuxdiyf.com/linux/13654.html

Ubuntu gcc g++ 4.4降级到4.3:http://www.linuxdiyf.com/linux/11815.html

Ubuntu更换gcc g++编译器默认版本:http://www.linuxdiyf.com/linux/2921.html