为什么我不能安装g ++?

尝试使用以下命令编译程序时: g++ -o

我发现了以下报告……

 The program 'g++' can be found in the following packages: * g++ * pentium-builder Try: sudo apt-get install  

然后我试着……

 nawshad@ubuntu:~/Thesis/Codes/Thesis_Utility_Function/Test Codes$ sudo apt-get install g++ Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: g++ : Depends: g++-4.6 (>= 4.6.3-1~) but it is not going to be installed libqt4-opengl : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed libqt4-svg : Depends: libqtcore4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed Depends: libqtgui4 (= 4:4.8.1-0ubuntu4.1) but 4:4.8.1-0ubuntu4 is to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution). 

但是由于未满足的依赖性而无法安装。

跑:

 sudo apt-get update 

在命令行上安装或升级软件包之前,应始终运行该软件包(除非您最近运行它)。 它从哪里获取有关哪些版本可用的软件包的信息。

你现在可以简单地安装g++ ,但是继续按照Web-E的说法(运行上面的命令之后)来修复任何当前损坏的依赖项:

 sudo apt-get -f install 

-f实际上可以在install之前或之后进行;效果是一样的。)

然后再尝试安装g++

 sudo apt-get install g++ 

如果仍然失败,请编辑您的问题以显示任何错误消息(以及运行它们时上述两个命令的输出)。 但它应该成功。