I am on Debian 7.9 and this question may seems very familiar to you, I have also seen some links, but when this was answered the GCC-5 was in testing place they suggested it as a work around, since we now been along with 6.X, is there any direct command like the below to install the newer version of G++

sudo apt-get g++-5(this doesn't work and say the pack not found)

And also its is more helpful if any suggestion passed along to replace the old g++ with the new one(if I successful with the installation)

  • 2
    If you are using Debian stable, g++ 4.9 is the newest thing you have. 5.3 is available in testing and 5.4 in unstable. Mixing stable with testing is not recommended (as that will introduce dependency conflicts) so there's no easy way to get a newer version in stable other than by taking the source code and building the version you wish for yourself. Well, that might not be easy, either, but at least it avoids the dependency hell.
    – zagrimsan
    Aug 3 '16 at 12:58

There is no release of Debian containing GCC 5 or 6, and there is no backport available — so there's no easy way for you to get GCC 5 or 6 in Debian. You could try rebuilding GCC 6 using the Debian packaging, but even that would be quite complex; the package needs to be bootstrapped, and if you're not familiar with it it's probably too complicated. (As it stands currently, the Debian packaging for GCC 5 needs GCC 6, so you might as well go straight for GCC 6).

That leaves a couple of possibilities:

  • you could build GCC from source and install it somewhere out of the way (/usr/local or /opt/gcc-6);
  • you could build on another distribution, e.g. Ubuntu 16.04 (which has GCC 5) or Debian testing or unstable (which have both GCC 5 and 6).

If you want to use the resulting binaries on Debian 7.9 you'll need to copy the appropriate libraries too, or build static binaries.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.