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++
Thanks, I followed your instructions and everything worked perfectly…!
Thank you it finally works now!
Thanks a lot! I looked since several weeks for a way to get a newer g++ on the raspberry pi. It worked fine.
jessie offers gcc 4.9 nowadays — September2014. gcc 4.8 can be replaced with gcc 4.9
Thx for the writeup.
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
thanks for this!
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
Thank you very much!
Have done it on Bananian (and a BananaPi).
Look like it’s working 🙂
Actually he is compiling MCServer
Perfect! Thanks a lot. Works also with g++-4.9.
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
I followed this isntructions but I also added some extra pinning to avoid systemd.
I used the last part of this: http://without-systemd.org/wiki/index.php/How_to_remove_systemd_from_a_Debian_jessie/sid_installation
after doing all of this and typing sudo rpi-source i get this: ERROR:
gcc version check: mismatch between gcc (4.8.4) and /proc/version (4.1.4)
Skip this check with –skip-gcc
Help: https://github.com/notro/rpi-source/wiki
Thank you! I only had to change 4.8 to 4.9 to get g++-4.9 working. This was much better than the misleading post below that only works for Raspberry Pi 2 which the title does not say: https://solarianprogrammer.com/2015/01/13/raspberry-pi-raspbian-install-gcc-compile-cpp-14-programs/
perfect instruction! thanks a lot.
Excellent instructions! Much thanks!
Thanks a lot… Things worked perfectly !
perfect !
This instruction is also applicable for gcc-4.9
Thanks for your help! Invaluable
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.
Thank you very much!
is it working with newer versions?