How to install GCC on Ubuntu 17.04

How to install GCC on Ubuntu 17.04

The GNU Compiler Collection (GCC) is a compiler system produced by the GNU project to support various programming languages. GCC is a key component of the GNU toolchain and the standard compiler for most UNIX like OS. It is mainly designed for C and C++ compiler. This tutorial explains the installation procedure of GCC on Ubuntu 17.04. 


Installation procedure

To start the installation process, add the repo to the terminal by executing the following command. 

root@linuxhelp1:~# add-apt-repository ppa:eugenesan/ppa
This repository contains collection of customized, updated, ported and backported
packages for two last LTS releases and latest pre-LTS release.
Packages for older releases relocated to ppa:eugenesan/archive or deleted.
| Disclaimer:
* Packages in this a nd related PPAs are for personal use only.
  They developed specifically for several custom environments and may not work for you.
* Usage of packages in this PPA, in some forms, might contradict licenses of software
  packaged in this and related PPAs. End users and administrator are responsible for
  runtime licensing and possible legal consequences.
* Some packages provided with their dependencies while some might require additional
  Ubuntu repositories and external PPAs. Below is the list of
gpg: keybox '/tmp/tmp3mbvc_er/pubring.gpg' created
gpg: /tmp/tmp3mbvc_er/trustdb.gpg: trustdb created
gpg: key E61380B28313A596: public key "Launchpad synergy+" imported
gpg: Total number processed: 1
gpg:imported: 1

The repositories are added to the target system. Now update the repo by using the apt-get update command

root@linuxhelp1:~# apt-get update
Hit:1 zesty-security InRelease
Get:2 zesty InRelease [15.4 kB]
Hit:3 zesty InRelease
Hit:4 zesty-updates InRelease
Hit:5 zesty-backports InRelease
Get:6 zesty/main i386 Packages [3,924 B]
Get:7 zesty/main amd64 Packages [3,916 B]
Get:8 zesty/main Translation-en [3,140 B]
Fetched 26.3 kB in 1s (18.7 kB/s)
Reading package lists... Done

The target system is updated with the required repositories. Install the GCC package by executing the following command. 

root@linuxhelp1:~# apt-get install gcc-4.9 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
cpp-4.9 gcc-4.9-base libasan1 libcloog-isl4 libgcc-4.9-dev
Suggested packages:
gcc-4.9-locales gcc-4.9-multilib gcc-4.9-doc libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan1-dbg liblsan0-dbg
libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libquadmath0-dbg
The following NEW packages will be installed:
cpp-4.9 gcc-4.9 gcc-4.9-base libasan1 libcloog-isl4 libgcc-4.9-dev
0 upgraded, 6 newly installed, 0 to remove and 55 not upgraded.
Need to get 13.2 MB of archives.
After this operation, 46.7 MB of additional disk space will be used.
Get:1 zesty/universe amd64 gcc-4.9-base amd64 4.9.4-2ubuntu1 [15.4 kB]
Get:2 zesty/universe amd64 libcloog-isl4 amd64 0.18.4-1 [60.5 kB]
Get:3 zesty/universe amd64 cpp-4.9 amd64 4.9.4-2ubuntu1 [5,205 kB]
Get:4 zesty/universe amd64 libasan1 amd64 4.9.4-2ubuntu1 [191 kB]
Get:5 zesty/universe amd64 libgcc-4.9-dev amd64 4.9.4-2ubuntu1 [2,063 kB]
Get:6 zesty/universe amd64 gcc-4.9 amd64 4.9.4-2ubuntu1 [5,681 kB]
Fetched 13.2 MB in 1min 27s (151 kB/s)
Selecting previously unselected package gcc-4.9-base:amd64.
(Reading database ... 168833 files and directories currently installed.)
Preparing to unpack .../0-gcc-4.9-base_4.9.4-2ubuntu1_amd64.deb ...
Unpacking gcc-4.9-base:amd64 (4.9.4-2ubuntu1) ...
Selecting previously unselected package libcloog-isl4:amd64.
Preparing to unpack .../1-libcloog-isl4_0.18.4-1_amd64.deb ...
Unpacking libcloog-isl4:amd64 (0.18.4-1) ...
Selecting previously unselected package cpp-4.9.
Preparing to unpack .../2-cpp-4.9_4.9.4-2ubuntu1_amd64.deb ...
Unpacking cpp-4.9 (4.9.4-2ubuntu1) ...
Selecting previously unselected package libasan1:amd64.
Preparing to unpack .../3-libasan1_4.9.4-2ubuntu1_amd64.deb ...
Unpacking libasan1:amd64 (4.9.4-2ubuntu1) ...
Selecting previously unselected package libgcc-4.9-dev:amd64.
Preparing to unpack .../4-libgcc-4.9-dev_4.9.4-2ubuntu1_amd64.deb ...
Unpacking libgcc-4.9-dev:amd64 (4.9.4-2ubuntu1) ...
Selecting previously unselected package gcc-4.9.
Preparing to unpack .../5-gcc-4.9_4.9.4-2ubuntu1_amd64.deb ...
Unpacking gcc-4.9 (4.9.4-2ubuntu1) ...
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Setting up libcloog-isl4:amd64 (0.18.4-1) ...
Processing triggers for man-db ( ...
Setting up gcc-4.9-base:amd64 (4.9.4-2ubuntu1) ...
Setting up cpp-4.9 (4.9.4-2ubuntu1) ...
Setting up libasan1:amd64 (4.9.4-2ubuntu1) ...
Setting up libgcc-4.9-dev:amd64 (4.9.4-2ubuntu1) ...
Setting up gcc-4.9 (4.9.4-2ubuntu1) ...
Processing triggers for libc-bin (2.24-9ubuntu2) ...

The package is installed in the target system. For checking the version of the installed package, execute the following command. 

root@linuxhelp1:~# gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2)

For removing the package, use the remove command to remove all the required repositories and the package. 

root@linuxhelp1:~# apt-get remove gcc-4.9 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
cpp-4.9 gcc-4.9-base libasan1 libcloog-isl4 libgcc-4.9-dev
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 55 not upgraded.
After this operation, 18.4 MB disk space will be freed.
(Reading database ... 169031 files and directories currently installed.)
Removing gcc-4.9 (4.9.4-2ubuntu1) ...
Processing triggers for man-db ( ...

Wasn't that an easy installation procedure? GCC accepts options and file names as operands. 

Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: Ubuntu GCC
user image Author :  Benjamin