我没有g++:
erelsgl@ubuntu:/etc/apt$ which g++
erelsgl@ubuntu:/etc/apt$
erelsgl@ubuntu:/etc/apt$ g++
The program 'g++' can be found in the following packages:
* g++
* pentium-builder
Try: sudo apt-get install <selected package>
因此我尝试安装它:
erelsgl@ubuntu:~/srilm$ 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 5 not upgraded.
2 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Setting up g++ (4:4.4.3-1ubuntu1) ...
update-alternatives: error: alternative path /usr/bin/g++ doesn't exist.
dpkg: error processing g++ (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of build-essential:
build-essential depends on g++ (>= 4:4.3.1); however:
Package g++ is not configured yet.
dpkg: error processing build-essential (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
g++
build-essential
E: Sub-process /usr/bin/dpkg returned an error code (1)
我也尝试安装 build-essential,并得到相同的结果。
我也尝试了“sudo apt-get update” - 没有帮助。
这是我的 apt 缓存:
erelsgl@ubuntu:/etc/apt$ apt-cache policy g++ build-essential
g++:
Installed: 4:4.4.3-1ubuntu1
Candidate: 4:4.4.3-1ubuntu1
Version table:
*** 4:4.4.3-1ubuntu1 0
500 http://il.archive.ubuntu.com/ubuntu/ lucid/main Packages
100 /var/lib/dpkg/status
build-essential:
Installed: 11.4build1
Candidate: 11.4build1
Version table:
*** 11.4build1 0
500 http://il.archive.ubuntu.com/ubuntu/ lucid/main Packages
100 /var/lib/dpkg/status
erelsgl@ubuntu:/etc/apt$
我也尝试了这个并得到了同样的错误:
erelsgl@ubuntu:~/Ace/Files/corpus$ sudo dpkg --configure -a
Setting up g++ (4:4.4.3-1ubuntu1) ...
update-alternatives: error: alternative path /usr/bin/g++ doesn't exist.
dpkg: error processing g++ (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of build-essential:
build-essential depends on g++ (>= 4:4.3.1); however:
Package g++ is not configured yet.
dpkg: error processing build-essential (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
g++
build-essential
答案1
听起来你当前的 g++ 安装有问题。首先删除它:
获取已安装的 g++ 包:dpkg --list 'g++'
去掉它:dpkg --purge g++XXXX
然后再次安装:apt-get install g++
synaptic
使用(gui)或(命令行)进入包aptitude
也可能会提供有关包状态的更多信息。
答案2
我在 Ubuntu 10.04 中没有找到针对此问题和其他类似问题的解决方案,因此最终我升级到了 12.04,现在一切正常...有时,软件包系统会出现混乱,因此最好的解决方案就是升级。
答案3
听起来 g++ 只安装了一半。尝试:
sudo dpkg --configure -a