How to Install GCC on Ubuntu

Install GCC ubuntu

GCC, an acronym standing for GNU Compiler Collection, is a collection of compilers for programming languages including C, C++, Objective-C, Fortran, Ada, Go, and D.

In this guide, we learn how to install GCC on Ubuntu 20.04.

Step 1: Update the system

First, make sure to update your Ubuntu system.

$ sudo apt update

Step 2: Install GCC on Ubuntu

Ubuntu default repository contains a meta-package named build-essential. This package contains GNU debugger, g++/GNU compiler collection other essential tools.

To install the build-essential package on Ubuntu, type:

$ sudo apt install build-essential

Step 3: Verifying GCC Installation

To verify that you have installed gcc and make run the command below

$ whereis gcc make


gcc: /usr/bin/gcc /usr/lib/gcc /usr/share/man/man1/gcc.1.gz
make: /usr/bin/make /usr/share/man/man1/make.1posix.gz /usr/share/man/man1/make.1.gz

Alternatively, you can run

$ gcc --version


gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

To get the version of make run

make -v


make --version

Next, we are going to install the dev man pages on Ubuntu distributions

Installation of dev man pages

To install the dev man pages run the following command

sudo apt install manpages-dev man-db manpages-posix-dev

To view library calls, run the following commands

# man 3 scanf
install GCC compilers
# man 2 execve
install GCC compilers
# man 2 fork
install GCC compilers

Now that we have confirmed the successful installation of the compilers and main components, let's test the GNU GCC compiler

Testing the GCC compiler

Let's first create a simple C++ program

vim test_app.cpp

Add the following code

// Simple C++ program to display "Hello World" 

// Header file for input output functions 

using namespace std; 

// main function - 
// where the execution of program begins 
int main() 
	// prints hello world 
	cout<<"Hello World ! \n"; 
	return 0; 

Next, compile the code as follows

g++ test_app.cpp -o test

Be sure to find a file called test in your directory using the ls command.

ls -l
install gcc compiler

Finally, run it as shown



Hello world !


We have successfully installed GCC on Ubuntu and compiled a Hello World example.

Thanks for reading, please provide your suggestions and feedback in the comment section.

Leave a Comment