Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have g++ 4.6, 4.7 and 4.8 installed, but not g++ itself. I am using Ubuntu 12.04. If I do:

g++ --version

it says:

The program 'g++' can be found in the following packages:
 * g++
 * pentium-builder

I have tried the following:

sudo apt-get update

then

sudo apt-get -f install

then

sudo apt-get install g++

but still I get the same when checking g++ version. Please help?

Doing apt-cache policy g++ yields:

g++:
  Installed: 4:4.6.3-1ubuntu5
  Candidate: 4:4.6.3-1ubuntu5
  Version table:
 *** 4:4.6.3-1ubuntu5 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
        100 /var/lib/dpkg/status
share|improve this question
    
1. Which ubuntu version do you have? 2. Please give us the output of the command apt-cache policy g++ –  medigeek Nov 3 '13 at 21:26
    
Edited my question at the bottom. I am using 12.04 (the "long term" stable release). –  mezamorphic Nov 3 '13 at 21:37

1 Answer 1

The package g++ is a metapackage that depends on the last version of g++. In raring it depends on g++-4.7:

apt-cache depends g++
g++
  Depends: cpp
  Depends: gcc
  Depends: g++-4.7
  Depends: gcc-4.7
  Suggests: g++-multilib
  Conflicts: g++:i386

The packages/binaries you are looking for is g++-4.8 and g++-4.7:

apt-cache policy g++-4.7
g++-4.7:
  Installed: 4.7.3-1ubuntu1
  Candidate: 4.7.3-1ubuntu1
  Version table:
 *** 4.7.3-1ubuntu1 0
        500 http://archive.ubuntu.com/ubuntu/ raring/main amd64 Packages
        100 /var/lib/dpkg/status

g++-4.8 isn't available in raring. To use any of them you have to imply them:

$ type g++
g++ is /usr/bin/g++
$ ls -l /usr/bin/g++
lrwxrwxrwx 1 root root 7 abr 22  2013 /usr/bin/g++ -> g++-4.7
$ type g++-4.7
g++-4.7 is /usr/bin/g++-4.7

If you have installed g++-4.7 you need to declare that you want to use g++-4.7.

share|improve this answer
    
I would like to use g++ 4.8, how do I do this? –  mezamorphic Nov 3 '13 at 22:01
    
askubuntu.com/a/346148/169736 –  Braiam Nov 3 '13 at 22:17
    
Thanks for the link but it only shows where to download the raw files. Once downloaded what would I have to do with them? (I need 4.8 because 4.7 gives me a compiler bug and apparently 4.8 has fixed this). –  mezamorphic Nov 3 '13 at 22:46
    
Also, when I do "type g++" it says "g++: not found" –  mezamorphic Nov 3 '13 at 22:47
    
"For the moment g++-4.8 doesn't exist in Ubuntu repositories since is still in unstable or testing version" is in the start. For the other problem either ask a another question, it means that you doesn't have the g++ symbolic link correctly. You may need to reinstall g++ and g++-4.6. –  Braiam Nov 3 '13 at 22:51

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.