0

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
Braiam
  • 66,947
  • 30
  • 177
  • 264
intrigued_66
  • 203
  • 5
  • 11

1 Answers1

2

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.

Braiam
  • 66,947
  • 30
  • 177
  • 264
  • I would like to use g++ 4.8, how do I do this? – intrigued_66 Nov 03 '13 at 22:01
  • http://askubuntu.com/a/346148/169736 – Braiam Nov 03 '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). – intrigued_66 Nov 03 '13 at 22:46
  • Also, when I do "type g++" it says "g++: not found" – intrigued_66 Nov 03 '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 03 '13 at 22:51
  • Yes I know it doesnt exist in Ubuntu repositories. But- you sent me a link which showed a 64 and 32 bit file for g++4.8. I asked what do I do with the file once I have downloaded it? – intrigued_66 Nov 03 '13 at 23:10
  • The reason is simple, g++ is too unstable to push it to the repositories, so, "simple methods" aren't deployed simply because everyone presumes that the user that wants the bleeding edge should know that they will have to dirty their hands. You should know [how to install a deb package](http://askubuntu.com/a/40781/169736) being careful of the dependencies. – Braiam Nov 03 '13 at 23:23