How do I install the latest version of gcc and g++?
I am using a variety of C++11 and C++1y features; which is why I need this.
You can install close to upstream version of GCC from Ubuntu Toolchain PPA: https://wiki.ubuntu.com/ToolChain#PPA_packages
Tested on Ubuntu 14.04.
teach a man to fish etc. etc.
How to build the source package and serve it from a local repository in an apt-friendly way. This will work on any distribution provided that dependencies can be satisfied/ This method does not require you to install build-deps for every package and polluting your machine with extraneous packages, this will let you keep up with packages as they get updated in debian experimental. It takes just a few minutes to do this once, and then can be reused to rebuild any package you need without relying on other people to package ppa for you or downloading a bunch of different .debs
The benefit of building vs. pulling raw .debs from debian is that this will build packages against the packages in your distribution which may differ in version/revision from what is used as build-dependencies for the debian distribution. This is more-or-less the process for backporting packages. You can also use any ubuntu distribution to build packages targeted at any other distribution (target in this case means build against the standard repository packages) with no hassle.
(not for ppa uploading - this has beurocratic requirements from launchpad
Easy backporting Dependencies
Using self-compiled packages to satisfy dependencies when building packages. (I have it set up with folders
Add the following to your
the script is a one-liner
Now any packages placed in
The VM solution
To do this in an even cleaner way, use a VM image or LXC container to jail this mess.
Applying custom patches
you can apply custom patches in most debian packages using
There is an additional step, you must rebuild the
Steps 1-4 here are pretty much what you need to upload to a PPA (they do not take binary files), but you require some steps to satisfy launchpad bureaucracy (this answer provides a explanation, this one has some links)
after that if you check the version of gcc you will find the old version
so we can fix it with simple symbolic
oryou can update using
// Actually i tried the symbolic & i know this will work but you may use the symbolic to get it without problems // please correct me if I am wrong
oryou can just compile with
gcc-4.9 is just like the gcc-4.8 "ubuntu 14.04 gcc" it is not a big deference
Debian offers a package: https://packages.debian.org/experimental/gcc-4.9 - To prevent causing issues with Ubuntu/Debian compatibility; don't add it to your sources.list.
Instead, simply download all these:
From Debian's servers, e.g.:
Then install them, e.g.:
[Easier just to run that bash loop a few times until all the dependencies are covered than remembering the order you downloaded them in!]
Currently (20141102) adding the PPA and invoking the above command
(skip the -dbg packages if they're of no interest to you), and then do an
I had to force the version for the gcc-4.9-base package to get past the error message you posted. Then installing worked
Now you can do the regular
Install GCC GNU 4.9
Remove the previous gcc version from the default applications list (if already exists)
Make GCC 4.9 the default compiler on the system
The latest update GCC 4.9.1 is a bug-fix release from the GCC 4.9 branch containing important fixes for regressions and serious bugs in GCC 4.9.0 with more than 88 bugs fixed since the previous release. In addition to that, GCC 4.9.1 release supports OpenMP 4.0 also in Fortran, rather than just in C and C++
Note : Checked on ubuntu 14.04 LTS