在Ubuntu 14.04上安装g ++ ccompiler时遇到问题
我尝试使用其他用户的软件包安装g ++。 离线..但有错误。 连接到网后,我尝试使用sudo apt-get install g++
,但它提供了以下输出:
gstreamer0.10-alsa is already the newest version. qtdeclarative5-ubuntu-ui-extras-browser-plugin is already the newest version. python-gconf is already the newest version. gstreamer0.10-tools is already the newest version. libglib2.0-0 is already the newest version. gir1.2-peas-1.0 is already the newest version. libatk-bridge2.0-0 is already the newest version. gnome-session-bin is already the newest version. libgomp1 is already the newest version. libmessaging-menu0 is already the newest version. usb-creator-gtk is already the newest version. libgnome-desktop-3-7 is already the newest version. software-properties-gtk is already the newest version. gnome-control-center-shared-data is already the newest version. unity-scope-gourmet is already the newest version. libcupsimage2 is already the newest version. growisofs is already the newest version. libjson-glib-1.0-common is already the newest version. activity-log-manager is already the newest version. libio-string-perl is already the newest version. qtdeclarative5-qtfeedback-plugin is already the newest version. gnome-power-manager is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
还有更多像这样的线……但g ++仍未安装
显然apt-get
不了解gcc
。
如果apt-get
知道名为g++
的包,它将不会尝试将g++
解释为单个包的名称。 (相反,我可以通过尝试安装类似命名的不存在的包q++
来重现您所看到的行为。)
apt-get
有两个可能的原因,不知道g ++ 包:
- 没有配置使用提供
g++
包的软件源。 - 提供
g++
软件源配置为使用,但从那时起,有关可用于安装的软件包的信息尚未更新。
如果是第二个原因,你可以运行sudo apt-get update
。 但我认为它更可能是第一个。
确保main已启用。
主存储库组件中 提供了g++
。 这应该几乎总是被启用,但也许不是。
工作的Ubuntu系统所需的许多软件包都是由主要组件提供的(这是由Canonical直接维护而不是由大型社区维护的软件,它主要由对许多Ubuntu系统很重要的核心软件组成)。 此外,一些apt-get
列出的软件包(例如python-gconf
)也是主要的。
所以我认为最近发生的事情主要是残疾,可能是偶然的。 apt-get
了解当前安装的main软件,因为它可以看到它已安装。 但是如果main被禁用,那么apt-get
不会知道你没有的主软件。
要检查main是否已启用,如果不是,请重新启用它,打开Software&Updates(在以前版本的Ubuntu上称为Software Sources)。 打开它的一种方法是单击Software Updater中的Settings …按钮(在旧版本的Ubuntu中称为Update Manager)。
然后确保选中标有“Canonical-supported free and open-source software(main)”的框。
如果它已经存在,那么很可能我猜错了你的问题的原因。 如果尚未选中,请选中该框(您可能需要输入密码),然后单击“关闭”。 你会被告知“有关可用软件的信息已经过时”; 单击“重新加载”按钮。
- 如果这是Ubuntu Server安装或没有GUI的其他系统,请参阅Kangarooo对如何启用“Universe”存储库 的回答 ? (只需启用main而不是Universe)。
然后再尝试安装g++
。
尝试使用其他APT镜像。
如果主要组件已经启用 ,那么您使用的APT镜像可能有问题。 特别是如果你没有使用其中一个官方镜子( us.archive.ubuntu.com
, us
用你的“国家代码”代替),我建议尝试使用另一个镜像,如果可能的话官方镜像。
您也可以在软件和更新中设置APT镜像。 只需在标有“从…下载”的下拉菜单中进行更改即可。
与启用软件源时一样,当您在更改下载服务器后退出软件和更新时,系统会提示您软件信息已过期,您应单击“重新加载”。 然后看看是否可以安装g++
。
- 如果这是Ubuntu Server安装或没有GUI的其他系统,请参阅如何将Ubuntu Server中的镜像从区域更改为主?
进一步排除故
如果仍然无法安装 ,那么您应该使用更多信息编辑您的问题,以帮助解决问题。
- 提供
/etc/apt/sources.list
的内容。 一种方法是复制命令cat /etc/apt/sources.list
的完整输出并将其粘贴到您的问题中。 选择它并按Ctrl + K进行正确格式化。 - 或者,您可能希望查看是否可以找到并安装g ++ 软件包中的软件包。 如果可以,太棒了! 更有可能的是,这样做可能会发现一些有用的信息,可以找出问题所在。