gcc 4.8 on Raspberry Pi Wheezy

Ever needed gcc/g++ 4.8 on your wheezy? Then do

sudo nano /etc/apt/sources.list

Change content to

deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
# Source repository to add
deb-src http://archive.raspbian.org/raspbian jessie main contrib non-free rpi

Add preferences file

sudo nano /etc/apt/preferences

and insert

Package: *
Pin: release n=wheezy
Pin-Priority: 900
Package: *
Pin: release n=jessie
Pin-Priority: 300
Package: *
Pin: release o=Raspbian
Pin-Priority: -10

update package list

sudo apt-get update

Install gcc/g++ 4.8 from jessie repositories

sudo apt-get install -t jessie gcc-4.8 g++-4.8

To remove gcc/g++ alternative configuration (if there is any, there is none by default)

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

Install alternatives

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

Now 4.8 is your default compiler. You can verify it by

sudo gcc --version

If you want to change it, you can

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

29 thoughts on “gcc 4.8 on Raspberry Pi Wheezy

  1. Hi Victor

    1. Thank you for the instructions… the gcc gets upgraded.
    2. Since the update I have severe upgrade issues because not all libraries were upgraded. So there is a mix of wheezy and jessie.
    So fixing upgrading all libraries manually is the only way to go.. or is it? Any guidance?

    Best regards
    Waldemar

    • After some work I have found that the easies way is:
      1. use ‘apt-cache show libkrb5-dev’ to show which versions are available
      2. then use ‘sudo apt-get install libkrb5-dev=1.12.1+dfsg-14’ to install the newest version

      After a few times of this I’ve managed to upgrade all the needed libs.

      Thanks again for the info.

      Br
      Waldemar

  2. Hola estoy siguiendo tus pasos y esta todos bien pero me sale un error al ejecutar esta linea “sudo nano /etc/apt/preferences”
    y me dice que no puede ser leida la lista de sources como puedo arreglar este esoero y me ayuden porfa… graciasss

  3. Thank you very much!

    Have done it on Bananian (and a BananaPi).

    Look like it’s working 🙂

    Actually he is compiling MCServer

  4. I am getting following error

    Unpacking libc6:armhf (from …/libc6_2.19-15_armhf.deb) …
    Selecting previously unselected package multiarch-support.
    Unpacking multiarch-support (from …/multiarch-support_2.19-15_armhf.deb) …
    dpkg: regarding …/libgcc1_1%3a4.9.2-10_armhf.deb containing libgcc1:armhf, pre-dependency problem:
    libgcc1 pre-depends on multiarch-support
    multiarch-support is unpacked, but has never been configured.

    dpkg: error processing /var/cache/apt/archives/libgcc1_1%3a4.9.2-10_armhf.deb (–unpack):
    pre-dependency problem – not installing libgcc1:armhf
    Errors were encountered while processing:
    /var/cache/apt/archives/libgcc1_1%3a4.9.2-10_armhf.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    please help

  5. Pingback: [Tutorial][Raspbian]How to install Xiaomi USB Dongle on Raspbian
  6. Pingback: [Tutorial][Raspbian]How to install Xiaomi USB Dongle on Raspbian | open education
  7. Pingback: Raspberry Pi Ethernet connection - BlogoSfera
  8. Pingback: Node.js v4.1.0 on Raspberry Pi 2
  9. Pingback: Homebridge Konfiguration | MyHomekit
  10. Pingback: Day Day Up ~ » 树莓派B+ debian wheezy安装gcc 4.8
  11. Pingback: RaspberryPi に nodejs の bluetooth-serial-port を npm install する。 | logger -s -t bisland 三日坊主
  12. Pingback: Setting up HTTPs for your Nodejs site using Express, Let’s Encrypt, GoDaddy and no-ip (Part 2) – The Delta Code Dump
  13. Great article. How do you also update ‘gdb’ so it can work with GCC 4.8? By just updating GCC, you are breaking your toolchain.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s