g++ 即使在安装 apt-get 之后也显示为已安装

g++ being shown as installed even after apt-get installation

所以当我第一次在控制台输入 g++ 进行检查时,会发生以下情况:

arunirc@fisher:~$ g++
The program 'g++' is currently not installed. You can install it by typing:
sudo apt-get install g++

按照建议,我安装了 g++(之前安装了 sudo apt-get update 和 -f)。

arunirc@fisher:~$ sudo apt-get install g++
Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 121 not upgraded.

但即使在它显示安装了 g++ 之后,这也是我在命令行中再次得到的:

arunirc@fisher:~$ g++
The program 'g++' is currently not installed. You can install it by typing:
sudo apt-get install g++

请帮忙! (我在 Ubuntu 14.04)。

编辑 1 (回应评论)

sudo update-alternatives --config g++ 给出此输出:

update-alternatives: error: no alternatives for g++

通过 Synaptic 查看是否有任何与 g++ 相关的内容并将其清除。

尝试使用

 locate /usr/bin/g++

{当这个过期时,使用 须藤更新 }

我的Ubuntu系统目前显示

:~$ locate /usr/bin/g++
/usr/bin/g++
/usr/bin/g++-4.9
/usr/bin/g++-5

下次使用

ls -lsa /usr/bin/g++

我的节目

0 lrwxrwxrwx 1 root root 5 Aug  1 14:32 /usr/bin/g++ -> g++-5

所以,我的 g++ 只是 link 到最新安装的 g++。

可能这个 link 丢失或安装不正确。

尝试手动设置 link。

但在此之前,请直接调用它。

/usr/bin/g++-5  --version

我的系统报告

g++-5 (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.