GCC can be used to compile many programming languages such as C, Objective C, C++, D, Go, Ada, and Fortran. This software is completely free and was originally developed by Free Software Foundation aka FSF.
Here we have guided you step-by-step on the procedure of installing GCC on the latest release of Ubuntu which is Ubuntu 22.04.
How to install GCC on Ubuntu 22.04
If you wish to install GCC on Ubuntu 22.04 then consult the guide provided below.
Step 1: Update the system
Before installing GCC, update your Ubuntu 22.04 by running the following command. This is done to make sure all the relevant packages are updated so that any conflict does not occur.
Step 2: Install GCC
Afterward, it is recommended to install the build-essential package that consists of packages of GCC and many other applications.
Step 3: Evaluate Installation
Now to verify the successful installation of GCC evaluate the C compiler version through the following command.
Step 4: Create a C program
Once installed, verify if the compiler is working properly or not by creating a simple C program. For instance, below we have created a simple hello world C program in nano editor and saved the file as helloworld.c.
Save this file and convert this into an executable one.
This command will generate a binary file by the name “helloworld” in the same directory. Now you have to execute the program using the below-mentioned command.
The C program was executed successfully.
Voila! GCC has been successfully installed on Ubuntu 22.04.
For the purpose of installing GCC on Ubuntu 22.04, first update it by using the command $ sudo apt update then install the build-essential package that contains the GCC package through the command $ sudo apt install build-essential. Then use the $ gcc –version command to verify the successful installation of GCC. Lastly, make a simple C program and compile and execute this program using these commands; $ gcc -o filename filename.c, and $ ./filename.