Installing g++ 7.0.1 on Debian 8.7

You can find similar in the Stack Overflow Unix pages To install the newest g++ from testing on debian, do the following: Add debian testing repo to your apt sources by creating a file (with .list extension) on /etc/apt/sources.list.d folder containing the line

deb http://ftp.us.debian.org/debian testing main contrib non-free

Instruct debian to use testing sources on certain packages by creating a file on /etc/apt/preferences.d containing the following:

Package: *
Pin: release a=testing
Pin-Priority: 100

You should name the file something like preferences or testingpref,etc. If you have a preferences file, you can add it there. Remove the .unused or any . in the filename.

Update database:

sudo apt-get update

Install g++:

sudo apt-get install -t testing g++

This will give you the most recent version of g++ in the repo. Thus it will receive updates and more-easily reversable. You need to use -t testing to get most recent versions. You may have dependency issues. It may be in experimental instead of testing for your architecture. See https://packages.debian.org/search?keywords=g%2B%2B

For experimental packages (7 is in there) add:

deb http://httpredir.debian.org/debian experimental main

to /etc/apt/sources.list . Similar to above.. pinning should say a=experimental instead of a=testing and lastly,

sudo apt-get install -t experimental g++

Good luck.


The kernel is irrelevant.

GCC 7 has not been released yet, as you can see in the GCC 7 release notes:

Disclaimer: GCC 7 has not been released yet, so this document is a work-in-progress.

You may want to learn about what makes different Linux distros different. In particular, what a rolling distribution is, and how Debian releases work. In a rolling distribution, all of the packages continually get updated to newer versions. Debian 8.7 (Jessie / stable) is not a rolling distribution. The packages versions are frozen and only updated when necessary, for extra stability. The latest version of GCC on Debian 8.7 is GCC 4.9.

Debian 9.0 (Stretch / testing) is a rolling release, at least until it gets frozen. If you switch your computer to Stretch you will get GCC 6.3.

If you need something newer, you can either switch to Sid (unstable), or pin packages from Sid.

However, GCC 7 is only available in experimental because it hasn't been released yet. You can install a single package from experimental if you like, see Debian Experimental for instructions.

Howto

Add to your /etc/apt/sources.list

https://wiki.debian.org/DebianExperimental

Then

apt-get update
apt-get -t experimental install gcc-7