How to install gcc 4.8.1 on debian wheezy

17,382

You could use something like this. However, it's not recommended.

If you really know what you're doing, you can try following:

Jessie (testing) now contains gcc-4.8 which is compliant with C++11 (also gcc-4.9 is available).

I used apt-pinning in the following way:

A source to jessie was added to /etc/apt/sources.list:

deb http://ftp.uk.debian.org/debian/ jessie main non-free contrib

/etc/apt/preferences was edited as such:

    Package: *
    Pin: release a=wheezy
    Pin-Priority: 900

    Package: gcc*
    Pin: release a=jessie
    Pin-Priority: 910

Then,

$ sudo aptitude update
$ sudo aptitude install gcc-4.8/jessie

$ ln -s /usr/bin/gcc-4.8 /usr/bin/gcc
$ sudo aptitude install g++-4.8/jessie
$ ln -s /usr/bin/g++-4.8 /usr/bin/g++

NOTE: Newer version of gcc might be dependend on newer libc6 which means that even if you compile your program with gcc-4.8, you won't be able to run the compiled program on other wheezy machine.

Share:
17,382

Related videos on Youtube

Mazzy
Author by

Mazzy

Updated on September 18, 2022

Comments

  • Mazzy
    Mazzy over 1 year

    I would like to install GCC 4.8.1 on my Debian Wheezy 7.1.0 system. The current version of GCC installed on my system is the 4.7.2. I see gcc-4.8.1 is available on the Debian repository. Can someone show me how to go about performing this update?

    • terdon
      terdon over 10 years
      Could you tell us why you would want to do that? It will almost certainly cause more problems than it will solve.
    • Mazzy
      Mazzy over 10 years
      Why should I have problems? This new gcc version has some problems?
    • terdon
      terdon over 10 years
      No, it is just that certain programs can have dependencies for specific versions. Unless you need a new feature that only exists in the latest version, updating gcc is not worth the effort and might break things. Why do you need to update?
    • Mazzy
      Mazzy over 10 years
      I would update to have the last version
    • terdon
      terdon over 10 years
      As I said, that is not a good idea unless you know that i) that will not break any dependencies and ii) there is something you need in the new version. Updating basic components like your system's compiler for no good reason is not a good idea.
    • Alen Milakovic
      Alen Milakovic over 10 years
      One option is to backport it to wheezy. I.e. rebuild the gcc 4.8.1 Debian sources on wheezy. This is non-trivial but doable.
    • Alen Milakovic
      Alen Milakovic over 10 years
      This is my answer to a similar question: Get newest gcc for debian?