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'
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With