How to install g++ 4.9 on Debian Wheezy armel?

user43995 picture user43995 · Aug 5, 2014 · Viewed 18.1k times · Source

My Debian 7 armel embedded system currently has g++ 4.6, and I'd like to upgrade to g++ 4.9 to use new C++11 features. How do I do that?

My current sources.list contents is:


    deb http://security.debian.org/ wheezy/updates main
    deb-src http://security.debian.org/ wheezy/updates main
    deb http://ftp.us.debian.org/debian wheezy main non-free
    deb-src http://ftp.us.debian.org/debian wheezy main non-free

A simple apt-get install of the package does not work:


    root@arm:~#  apt-get install g++-4.9
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package g++-4.9
    E: Couldn't find any package by regex 'g++-4.9'

Answer

Laryx Decidua picture Laryx Decidua · Apr 19, 2015

Another workaround could be to install the g++ 4.9 packages from "Jessie", according to this blog post. Briefly, you would have to tell APT to use the Jessie repos while you are installing the new G++. First bring the current Wheezy up-to-date:

sudo apt-get update
sudo apt-get upgrade

Then do a backup :-) and edit /etc/apt/sources.list so that you replace the string "wheezy" with "jessie":

sudo cp /etc/apt/sources.list /etc/apt/sources.list.WHEEZY
sudo vi /etc/apt/sources.list

Now update the package list and install the 4.9 version of GCC/G++:

sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9

After this revert to the "original" package list:

sudo cp /etc/apt/sources.list.WHEEZY /etc/apt/sources.list
sudo apt-get update

This leaves the original GCC,G++ in place. If you wish to compile with the 4.9 version, then either set the CC and CXX env vars accordingly or invoke the compilers as gcc-4.9 or g++-4.9 explicitly.