The GNU Compiler Collection (GCC) is a powerful compiler system that supports various programming languages including C and C++. The latest versions of Ubuntu does not have this by default. You can install it by following the 5 simple steps:
Step 1. First open the terminal and type “gcc” to check whether the package is already installed or not. If the package is already installed in your system, then you can start using it. Otherwise, follow the next steps.
Step 2. It is recommended to do a package update first, so that it will update package lists and all versions that matches with the latest version of GCC nicely. To update:
sudo apt-get update
sudo apt-get upgrade
Step 3. Installing the metapackage called build-essential is the best way to get GCC. It contains a list of packages which are essential for building Ubuntu packages including GCC compiler, make and other required tools. To install it, type in the terminal:
sudo apt-get install build-essential
Step 4. Accept the installation.
Step 5. To check the version of installed GCC compiler, type the following in the terminal:
Now you are all set to use the GCC compiler.
If you do not want to install the the whole build-essential metapackage, you can simply install only the GCC package by giving the following command in terminal:
sudo apt-get install gcc g++