尝试使用以下命令编译程序时:
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>
然后我尝试...
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).
由于未满足依赖关系,我无法安装。
更新时,出现以下错误:
nawshad@ubuntu:~$ sudo apt-get update
[sudo] password for nawshad:
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
我按照以下说明进行操作无法锁定管理目录(/var/lib/dpkg/),是否有另一个进程正在使用它?),但未满足的依赖关系仍未得到解决。
答案1
跑步:
sudo apt-get update
您应该始终在命令行上安装或升级软件包之前运行它(除非您最近才运行过它)。它会获取有关哪些软件包在哪个版本中可用的信息。
您可能现在就可以安装g++
,但请继续按照 Web-E 所说的操作(运行上述命令后),修复任何当前损坏的依赖项:
sudo apt-get -f install
(-f
实际上 可以放在 之前或之后install
;效果是一样的。)
然后尝试g++
再次安装:
sudo apt-get install g++
如果仍然失败,请编辑你的问题显示任何错误消息(以及还运行上述两个命令时的输出)。但它应该会成功。