Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I don't have 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>

So I try to install it:

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)

I also try to install build-essential, and get same results.

I also tried "sudo apt-get update" - didn't help.

This is my apt-cache:

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$ 

I also tried this and got the same error:

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
share|improve this question
    
Looks like you're running Ubuntu Lucid. Could you add the output of apt-cache policy g++ build-essential? –  Lekensteyn Dec 15 '11 at 10:08
    
You are right! I added the output. –  Erel Segal Halevi Dec 15 '11 at 10:16

3 Answers 3

Sounds like there is a problem with your current g++ installation. First remove it:

Get your installed g++ package: dpkg --list 'g++'

Remove it: dpkg --purge g++XXXX

Then install it again: apt-get install g++

Going to the package with synaptic (gui) or aptitude (command-line) might also give more information about the status of the package.

share|improve this answer
    
This sounds promising, however I cannot figure out the output: erelsgl@ubuntu:~/Ace/Files/corpus$ sudo dpkg --list 'g++' Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Description +++-==============-==============-============================================ iF g++ 4:4.4.3-1ubunt The GNU C++ compiler –  Erel Segal Halevi Dec 18 '11 at 8:01
    
It seems I have version 4.4.3, but I cannot remove it: erelsgl@ubuntu:~/Ace/Files/corpus$ sudo dpkg --purge 'g++4.4.3' dpkg: warning: ignoring request to remove g++4.4.3 which isn't installed. I also tried 'g++-4.4.3', 'g++4.4.3-1ubunt', 'g++4.4.3-1ubuntu' 'g++-4.4.3-1ubunt', 'g++-4.4.3-1ubuntu' - I probably miss the correct variant –  Erel Segal Halevi Dec 18 '11 at 8:02
    
try just "dpkg --purge g++" –  dtech Dec 22 '11 at 11:04
    
OK, the purge worked, but the install still gives the same error... –  Erel Segal Halevi Jan 1 '12 at 11:10

It sounds like g++ is half-installed. Try:

sudo dpkg --configure -a
share|improve this answer
    
I tried this and got the same error - see my latest edit above. –  Erel Segal Halevi Dec 18 '11 at 7:59
up vote 0 down vote accepted

I didn't find a solution to this and other similar problems in my Ubuntu 10.04, so finally I upgraded to 12.04 and now everything works fine... Sometimes, the package system gets confused, so the best solution is just to upgrade.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.