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

Raspberry Pi World Domination?

Christmas time. Time to talk to people you do not meet regularily. And what do they answer if you ask if they have ever heard about Raspberry Pi? “Oh, yes! I have one since summer.”, “Cool gadget. Mine hasn’t arrived, yet.”, “I’m planning to get one to see what I can do with it.”.

Well, not bad, RPi. World domination is just a step away. Everybody loves you. They don’t know what you are or even what your capabilities are.

But you are the IT-GADGET!