How do I use the latest GCC on Ubuntu?


Thank you for asking this question, it helped me a lot to recall all the stuff regarding Ubuntu.

If you simply install GCC 4.9.0 in Ubuntu 14.04 definitely it will get install by using following lines of command but still system will not set it as your default compiler.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.9

Now after this you can check which version of GCC is your default compiler by writing this command .

gcc -v

When I executed this command, GCC 4.8.4 was shown as a default compiler.

Check the 1st and 2nd last line in the terminal.

Now as we know that GCC 4.9 has installed but it is not working as a default compiler. So to set it as a default compiler following commands should be executed that is shown in picture.

After executing all the above commands sequentially, GCC 4.9 will get set as a default compiler, but do not forget to replace 4.3 with 4.8 and 4.4 with 4.9....

0 0

GNU compiler collection was originally written as the compiler for the GNU operating systems and was developed to be 100% free software. GCC includes front ends for C, C++, Objective-C, Fortran, Ada, and Go, as well as libraries for these languages (libstdc++,…).

How To Install Latest GNU Compiler Collection (GCC) on Ubuntu 14 and Ubuntu 16

sudo apt-get update && \ sudo apt-get install build-essential software-properties-common -y && \ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ sudo apt-get update && \ sudo apt-get install gcc-snapshot -y && \ sudo apt-get update && \ sudo apt-get install gcc-6 g++-6 -y && \ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \ sudo apt-get install gcc-4.8 g++-4.8 -y && \ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;

When completed, you must change to the gcc you want to...

0 0

The regular procedure to build any program from source code is simply the below three steps:

1) First, we need to build dependencies before we can install gcc: apt-get install build-essential


So first of all, we should get the latest version of gcc from its offical site or any mirror site.

You can manually download from the mirror site or use command:

sudo wget 2:

After we download the source code, we unzip(for *tar.bz2 files, use command: tar -xjf filename) it to a temporary directory, usually $HOME/Downloads or /opt. actually it doesn't matter where you put because we will delete them after we compile the source successfully.

Enter the directory that you unzipped just now, say in $HOME/Downloads/gcc-5.3, then type command:

./configure --disable-checking --enable-languages=c,c++,objc --disable-multilib --with-system-zlib...
0 0