45

I have Ubuntu 10.04 32-bit with gcc 4.4.3 currently installed on it. I want to upgrade it to gcc 4.6.1.

  1. How to update using Ubuntu Package Manager:

    apt-get upgrade/install
    
  2. As a second option I downloaded the latest gcc snapshot file from:

    http://gcc.cybermirror.org/snapshots/LATEST-4.7/gcc-4.7-20110709.tar.bz2

How do I configure, compile, and install it?

Gaff
  • 18,569
  • 15
  • 57
  • 68
goldenmean
  • 2,437
  • 21
  • 61
  • 72
  • 1
    Btw, Ubuntu specific questions can also be asked at [Ask Ubuntu](http://askubuntu.com) StackExchange site. – Ilari Kajaste Jul 15 '11 at 07:28
  • 2
    [How to install and use GCC g++ v4.7 and C++11 on Ubuntu 12.04](http://charette.no-ip.com:81/programming/2011-12-24_GCCv47/). – iammilind Apr 22 '13 at 03:06

3 Answers3

43

Add https://launchpad.net/~ubuntu-toolchain-r/+archive/test to your repositories by running:

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

Then follow the steps on AskUbuntu to map gcc to the version you just installed.

In our case, you want to run:

sudo apt-get update
sudo apt-get install gcc-4.6
sudo apt-get install g++-4.6
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
Gili
  • 1,841
  • 4
  • 26
  • 37
  • 1
    +1, this worked for me. The last line needs code formated but it wasn't a big enough edit to allow the change. – Nick Apr 26 '12 at 17:49
11

I think you can get it by adding this PPA to your repositories:

https://launchpad.net/~ubuntu-toolchain-r/+archive/test

You can add the PPA by running

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

After it's in the repositories (and after running apt-get update) you should be able to either 1) update to the latest version using apt-get upgrade, or possibly 2) you'll have it available as a separate package you need to you'll need to apt-get install. I'm not sure which is the case with this package.

Further information: Guide on how to add a PPA to your repositories.

Ilari Kajaste
  • 3,503
  • 6
  • 37
  • 43
  • 4
    Did not work. After `sudo add-apt-repository ppa:ubuntu-toolchain-r/test` and `sudo apt-get update`, both `sudo apt-get upgrade gcc` and `sudo apt-get upgrade g++-4.7` did nothing. I have a stock 11.10 64bit install. – voltrevo Dec 23 '11 at 21:44
2

You don't get latest anything on LTS with the package manager. It's supposed to be stable with backported security updates. I'm not a fan of updating distros, I just reinstall and copy ~/

  
./configure
make
make install  

is the general procedure. Read the options in the configure script...you have to have a version installed to compile a new one. make install will probably mangle your current install.

suggestion: if you want "newest" then use "newest" - that's 11.10 at this point I think.

RobotHumans
  • 5,904
  • 1
  • 19
  • 25