How to install c c compiler and development tools in ubuntu

Many of the Linux engineers are required to do some general programming languages to automate their normal tasks This article explains how to install C and C++ compilers and it’s development tools (build-essential) and related packages such as make,libc-dev,dpkg-dev, etc in Linux.
Before getting into installation part, It is better if we can know about compiler.
“A compiler is a software program that processes statements written in a particular programming language and creates a binary file which the machine’s CPU can easily understand and executes them”
If Build-Essential Tools are not installed in your system then, use the following command-
$ sudo apt-get install build-essential
The output should be like this –
Reading state information... Done
The following packages were automatically installed and are no longer required:
gcc-4.8-base:i386 libasn1-8-heimdal:i386 libasound2:i386
libasound2-plugins:i386 libasyncns0:i386 libavahi-client3:i386
libavahi-common-data:i386 libavahi-common3:i386 libbit-vector-perl
libcapi20-3:i386 libcarp-clan-perl libclass-method-modifiers-perl
libcups2:i386 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libedit2:i386 libelf1:i386 libexif12:i386 libexpat1:i386
libffi6:i386 libflac8:i386 libfontconfig1:i386 libfreetype6:i386
libgcrypt11:i386 libgd-perl libgd3:i386 libgif4:i386
libgl1-mesa-dri-lts-wily:i386 libgl1-mesa-glx-lts-wily:i386
libglapi-mesa-lts-wily:i386 libglib2.0-0:i386 libglu1-mesa:i386
libgnome2-gconf-perl libgnutls26:i386 libgpg-error0:i386 libgphoto2-6:i386
libgphoto2-port10:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386
libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386
libhcrypto4-heimdal:i386 libheimbase1-heimdal:i386 libheimntlm0-heimdal:i386
libhx509-5-heimdal:i386 libice6:i386 libieee1284-3:i386
libjack-jackd2-0:i386 libjbig0:i386 libjpeg-turbo8:i386 libjpeg8:i386
libk5crypto3:i386 libkeyutils1:i386 libkrb5-26-heimdal:i386 libkrb5-3:i386
libkrb5support0:i386 liblcms2-2:i386 libldap-2.4-2:i386 libllvm3.6:i386
libltdl7:i386 libmouse-perl libmpg123-0:i386 libnet-dropbox-api-perl
libogg0:i386 libopenal1:i386 liborc-0.4-0:i386 libosmesa6:i386
libp11-kit-gnome-keyring:i386 libp11-kit0:i386 libpciaccess0:i386
........................
We should delete old cache files to speed up compilation. To install cache management tool, use the following commands-
$ sudo apt-get install aptitude
The output should be like this –
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gcc-4.8-base:i386 libasn1-8-heimdal:i386 libasound2:i386
libasound2-plugins:i386 libasyncns0:i386 libavahi-client3:i386
libavahi-common-data:i386 libavahi-common3:i386 libbit-vector-perl
libcapi20-3:i386 libcarp-clan-perl libclass-method-modifiers-perl
libcups2:i386 libdata-random-perl libdate-calc-perl libdate-calc-xs-perl
libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libedit2:i386 libelf1:i386 libexif12:i386 libexpat1:i386
libffi6:i386 libflac8:i386 libfontconfig1:i386 libfreetype6:i386
libgcrypt11:i386 libgd-perl libgd3:i386 libgif4:i386
libgl1-mesa-dri-lts-wily:i386 libgl1-mesa-glx-lts-wily:i386
libglapi-mesa-lts-wily:i386 libglib2.0-0:i386 libglu1-mesa:i386
libgnome2-gconf-perl libgnutls26:i386 libgpg-error0:i386 libgphoto2-6:i386
libgphoto2-port10:i386 libgssapi-krb5-2:i386 libgssapi3-heimdal:i386
libgstreamer-plugins-base0.10-0:i386 libgstreamer0.10-0:i386
libhcrypto4-heimdal:i386 libheimbase1-heimdal:i386 libheimntlm0-heimdal:i386
libhx509-5-heimdal:i386 libice6:i386 libieee1284-3:i386
libjack-jackd2-0:i386 libjbig0:i386 libjpeg-turbo8:i386 libjpeg8:i386
libk5crypto3:i386 libkeyutils1:i386 libkrb5-26-heimdal:i386 libkrb5-3:i386
libkrb5support0:i386 liblcms2-2:i386 libldap-2.4-2:i386 libllvm3.6:i386
libltdl7:i386 libmouse-perl libmpg123-0:i386 libnet-dropbox-api-perl
libogg0:i386 libopenal1:i386 liborc-0.4-0:i386 libosmesa6:i386
libp11-kit-gnome-keyring:i386 libp11-kit0:i386 libpciaccess0:i386
libpulse0:i386 libroken18-heimdal:i386 libsamplerate0:i386 libsane:i386
libsasl2-2:i386 libsasl2-modules:i386 libsasl2-modules-db:i386 libsm6:i386
libsndfile1:i386 libspeexdsp1:i386 libsqlite3-0:i386 libssl1.0.0:i386
libstdc++6:i386 libtasn1-6:i386 libtiff5:i386 libtxc-dxtn-s2tc0:i386
libusb-1.0-0:i386 libv4l-0:i386 libv4lconvert0:i386 libvorbis0a:i386
...................................
Now install ccache tool using aptitude as shown below –
$ sudo aptitude install ccache
The sample output should be like this –
The following NEW packages will be installed:
ccache
The following packages will be REMOVED:
gcc-4.8-base:i386{u} libasn1-8-heimdal:i386{u} libasound2:i386{u}
libasound2-plugins:i386{u} libasyncns0:i386{u} libavahi-client3:i386{u}
libavahi-common-data:i386{u} libavahi-common3:i386{u}
libbit-vector-perl{u} libcapi20-3:i386{u} libcarp-clan-perl{u}
libclass-method-modifiers-perl{u} libcups2:i386{u} libdata-random-perl{u}
libdate-calc-perl{u} libdate-calc-xs-perl{u} libdrm-amdgpu1:i386{u}
libdrm-intel1:i386{u} libdrm-nouveau2:i386{u} libdrm-radeon1:i386{u}
libedit2:i386{u} libelf1:i386{u} libexif12:i386{u} libexpat1:i386{u}
libffi6:i386{u} libflac8:i386{u} libfontconfig1:i386{u}
libfreetype6:i386{u} libgcrypt11:i386{u} libgd-perl{u} libgd3:i386{u}
libgif4:i386{u} libgl1-mesa-dri-lts-wily:i386{u}
libgl1-mesa-glx-lts-wily:i386{u} libglapi-mesa-lts-wily:i386{u}
libglib2.0-0:i386{u} libglu1-mesa:i386{u} libgnome2-gconf-perl{u}
libgnutls26:i386{u} libgpg-error0:i386{u} libgphoto2-6:i386{u}
libgphoto2-port10:i386{u} libgssapi-krb5-2:i386{u}
libgssapi3-heimdal:i386{u} libgstreamer-plugins-base0.10-0:i386{u}
.........................................
For instance, to test a C program, create a file called sum.c and add the following command-
#include
int main()
{
   int a, b, c;
   printf("Enter two numbers to add: ");
   scanf("%d%d",&a,&b);
   c = a + b;
   printf("The sum of two numbers equals %d\n",c);
   return 0;
}
The above command gives the result of a sum of two numbers. To compile the above code into an executable named sum in the current working directory use the -o switch with gcc–
$ gcc sum.c -o sum
To use ccache command, use the following command-
$ ccache gcc sum.c -o sum
To run binary command, use the following command –
$ ./sum
The sample output should be like this –
$ ./sum
Enter two numbers to add: 24 54
The sum of equals 78
Congratulations! Now, you know “How to Install C, C++ Compiler and Development Tools in Ubuntu”. We’ll learn more about these types of commands in our next Linux post. Keep reading!