Where can I find a g++ 4.7 package?

25,234

The Toolchain test builds PPA contains many packages including gcc-4.7.

You can add the repository using

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

Then, to install it use

sudo apt-get update
sudo apt-get install g++-4.7

To change the default compiler use update-alternatives

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
sudo update-alternatives --config gcc
Share:
25,234

Related videos on Youtube

Griwes
Author by

Griwes

Chair of the Polish delegation to ISO/IEC JTC 1/SC 22/WG 21, the C++ Standards Committee. BEng in the field of Computer Science from Wrocław University of Technology, working on C++ libraries at Nvidia; programming enthusiast and someone interested in reinventing the wheel the hard way - hence all the projects at my Github page.

Updated on September 18, 2022

Comments

  • Griwes
    Griwes almost 2 years

    Some time ago, I managed to find PPA featuring g++-4.7 build. However, I had to reinstall everything on my machine and I lost name of that PPA. Could anyone point me to it? I tried to find it again, but without any luck. I'm on Ubuntu 11.10 installation.

    • Thomas Ward
      Thomas Ward over 12 years
      I strongly recommend you do not install 4.7 in place of gcc that is with your version. If you do, you run the risk of breaking your system.
    • Griwes
      Griwes over 12 years
      @ThomasWard: I know, I am not a complete newbie.
    • Gearoid Murphy
      Gearoid Murphy over 11 years
      @Griwes, you may not be a 'newbie' but others might be and his observation is correct.
    • Eliah Kagan
      Eliah Kagan over 11 years
      Related. (But if we decide that's a duplicate of this, we should make sure to ask for answers to be merged, as that's about what to do when this doesn't work.)
  • Griwes
    Griwes over 12 years
    Well, I cannot find it now, but I recall doing apt-get install g++-4.7 gcc-4.7...
  • Ugo
    Ugo about 12 years
    Did not work for me. I only see gcc-4.6 (on ubuntu 11.10)
  • expert
    expert almost 12 years
    How can I uninstall g++-4.6 without uninstalling g++ ? Currently I have packages g++, g++-4.6 and g++-4.7 installed. as result g++ --version gives me version 4.6.
  • expert
    expert almost 12 years
    Ah perhaps I need simply rename g++-4.7 to g++
  • Lee Goddard
    Lee Goddard over 8 years
    sudo: add-apt-repository: command not found $ sudo apt-get install software-properties-common python-software-properties