22

I have Ubuntu 10.04 32-bit with gcc 4.4.3 currently installed on it. I want to upgrade it to gcc/g++ 4.7 (I am looking for C++ 0x support)

How to update using Ubuntu Package Manager:

apt-get upgrade/install ??

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

Would doing

./configure
make  
make install 

on this package build and install it from source?

| improve this question | | | | |
16

12.04

Add the toolchain ppa test repository, then do apt-get update, and apt-get dist-upgrade

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.7 c++-4.7

This is only available in 12.04 - older ubuntu versions cannot be updated to this same version using this method.

See here for further information about PPAs
https://help.launchpad.net/Packaging/PPA

| improve this answer | | | | |
  • 1
    you mean sudo apt-get install gcc-4.7 c++-4.7? There must be something wrong because typing "gcc --version" after doing that still returns 4.6.3 – user2413 Jul 5 '12 at 11:15
  • 1
    @user2413 this installs g++4.7 as a separate program and you could use g++-4.7 *.cpp; what you may want is sudo apt-get upgrade – manuzhang Feb 12 '13 at 12:01
  • Worked for me on 10.04, without the c++-4.7 part. – Ajith Apr 8 '13 at 9:42
  • 1
    WARNING: It work for me on quantal (12.10), but it removed acroread, valgrind no longer works and I couldn't attach gdb to a running process. – sehe Sep 7 '13 at 14:49
  • 1
    Watch out, check the section The following packages will be REMOVED. On Ubuntu 10.04 the install g++4.7 command above wanted to remove 100s of packages including my xserver, gnome desktop, eclipse, chrome, xulrunner, etc... – jcalfee314 Feb 10 '14 at 0:56
4
sudo apt-get install gcc-snapshot

Then, invoke it with:

/usr/lib/gcc-snapshot/bin/gcc

For the second part of the question, the answer is "yes, sort of". If you really want to do that (i.e. installing the gcc-snapshot package isn't enough) then you'll need to install the dependencies:

sudo apt-get build-dep gcc-snapshot

Then, find the correct configure options:

gcc -v

(and modify the install path etc.)

Then, build like this:

mkdir objdir
cd objdir
../gcc-src-dir/configure ......insert..options..here...
make
make install
| improve this answer | | | | |
  • BTW, if you do build from source, expect problems linking crti.o. Search other questions here for solutions how to fix that. – ams Nov 15 '11 at 15:16
  • 1
    In 10.04 this instructions bring gcc-4.5 (not 4.6 or 4.7), as reported by /usr/lib/gcc-snapshot/bin/gcc -v – alfC Dec 14 '11 at 7:48
1

10.04 LTS

Use the following command to install add-apt-repository:

apt-get install python-software-properties

Then add the tooclain ppa test repo as described for 12.04 LTS.

| improve this answer | | | | |
  • 1
    This seems to be saying to install the package that provides the Software Sources window, then once you have that, you can go ahead and use the Software Sources window to add the PPA. But the Software Sources window certainly does exist in 10.04; you don't have to install anything to get it! Also, the method this refers to for adding the PPA doesn't require opening the Software Sources window or using the GUI at all. @Plexo, can you explain further or expand on this? – Eliah Kagan Jun 17 '12 at 9:15
1

How to install gcc 4.8 on Ubuntu 10.04:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Verify gcc version with:

g++ --version

It worked on my machine. Source: http://ubuntuhandbook.org/index.php/2013/08/install-gcc-4-8-via-ppa-in-ubuntu-12-04-13-04/

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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