Steps to Install GCC on Ubuntu 20.04 LTS ?

GCC stands for GNU Compiler Collection. From its name, you can easily perceive that it is basically a group of compilers for different programming languages such as C, C++, FORTRAN, Ada, and so on.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Packages installation on Linux Based Servers.
In this context, we shall look into how to install GCC on Ubuntu 20.04 LTS.

Steps to install GCC on Ubuntu 20.04 ?

To install GCC on Ubuntu 20.04, follow the steps provided below;
1. Updating the System:
The first thing you need to do is to launch the terminal by looking for it in the Activities menu. Once the terminal window is there in front of you, you need to update the cache to fix any potential broken packages or dependencies. This can be done by executing the command stated below in your Ubuntu 20.04 terminal:

sudo apt update

2. Installing the build-essential package
Now, the build-essential package should be installed in which GCC resides. You can have this package on your system by executing the command shown below:

sudo apt install build-essential

3. Installing the Manual Pages
Additionally, you can also install the manual pages for this package for assisting you whenever you get stuck while using it. You can install the manual pages with the help of the following terminal command:

sudo apt-get install manpages-dev

After executing this command, the manual pages for these packages will be installed on your system.

4. Verifying the Installation:
Once the installation of GCC has been successfully carried out, you can confirm with the help of the following command:

gcc --version

Executing this command will display the version of GCC installed on your Ubuntu 20.04 terminal.

5. Creating a Test Program
After installing GCC on Ubuntu 20.04, you might want to see whether this compiler is working properly or not. To check the working of GCC, you need to create a test program. We will be writing a program in C language for demonstrating the usage of GCC. First, we will create a file with the .c extension via the terminal by running the following command in it:

sudo nano FileName.c

You can also use any other text editor of your choice if you do not want to use the nano editor. FileName is just a dummy name which is to be replaced by the name of the file that you have created. For our particular example, we have named it as FirstProgram.c.

sudo nano FirstProgram.c

Running the above-mentioned command will create a new file with the .c extension and will open it in the nano editor. Once the newly created file is opened in front of you, type the code shown in the image below in your newly created file. Here, the first line of the code includes the stdio.h library to your program with the help of which you can easily run the input and output commands. Then in the main() function of the program, we have simply printed a message by making use of the printf command. The “\n” parameter in the message is used to introduce a new line delimiter. The “return 0” statement will simply return an integer value to the main function after the successful execution of this program. After typing the code shown in the image below in your file, press Ctrl+ X to save it and to exit from the nano editor.

6. Compiling the Test Program
Now you need to compile this newly created program to create its executable file by running the following command in your terminal:

gcc FirstProgram.c –o FirstProgram

Here, the first FirstProgram indicates the .c file that we have just created whereas the second FirstProgram is the name that will be given to the executable file after running this command. You can also have any other name of your choice for this executable file.

7. Running the Test Program
Once the executable file has been created, you can simply run it by executing the following command in your terminal:


Running this command will simply execute your FirstProgram file and will display its output on the terminal.

[Need urgent support to Install Software on Ubuntu? We are available to help you. ]

This article will guide you on the steps to install #GCC on Ubuntu 20.04. Also you will learn the method of running a basic C program by making use of this #compiler. To install GCC on #Ubuntu: 1. Start by updating the packages list: sudo apt update. 2. Install the build-essential package by typing: sudo apt install build-essential. 3. To validate that the GCC compiler is successfully installed, use the gcc --version command which prints the GCC version: gcc --version.

Related Posts