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

MiN*_*EaK 7 installation compiling g++

尝试使用以下命令编译程序时: g++ -o <output_file> <my_file.cpp>

我发现了以下报告......

The program 'g++' can be found in the following packages:
 * g++
 * pentium-builder
 Try: sudo apt-get install <selected package>
Run Code Online (Sandbox Code Playgroud)

然后我试了...

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).
Run Code Online (Sandbox Code Playgroud)

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

Eli*_*gan 6

跑:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

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

g++现在可能只是能够安装,但继续按照 Web-E 所说的(在运行上述命令后)修复任何当前损坏的依赖项:

sudo apt-get -f install
Run Code Online (Sandbox Code Playgroud)

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

然后g++再次尝试安装:

sudo apt-get install g++
Run Code Online (Sandbox Code Playgroud)

如果还是失败,请编辑您的问题表现出任何的错误消息(和的输出上面的两个命令,当你跑了它们)。但它应该会成功。