Linux--ubuntu 14.04 install g++問題

Ubuntu 10.10通過 sudo apt-get install g++ 出現“g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed”錯誤。

是因爲ubuntu 10.10的源過舊或不可訪問導致,可以通過更新源解決。


首先,備份原始源文件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

轉載自:http://www.linuxdiyf.com/linux/15487.html


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章