Ubuntu

How to Install and Use Build Essential Tools on Ubuntu 22.04

Before proceeding towards installing and using the build-essential tools, we will first understand what they are and how they help us? This is the package available in Ubuntu that contains the dependencies of other packages, especially the Debian packages and the compilers for different programming languages.

This write-up will help you understand the installation procedure of Build essentials on Ubuntu with the example of its usage.

How to install and use Build Essential Tools on Ubuntu?

For the installation of the build-essential tools package from the official repository of Ubuntu, execute the mentioned-below command:

$ sudo apt install build-essential -y

Well, as it has been discussed in the above section that the package of build-essential contains different compilers so to validate this statement, we will check the installed version of the GCC compiler that is included in the build essentials tools and is used to compile the code of C programming language:

$ gcc --version

In the above output, the version “11.2.0” of GCC is confirming that it has been installed, with the installed packages of Build Essentials.

To confirm the working of the compiler, we will write a simple C program to display the “Welcome to the LinuxHint” message. So, we will create a file with the name of “MyCfile” with the nano text editor:

$ nano MyCfile.c

Copy and paste the below script in your opened nano editor in the terminal:

#include <stdio.h>

int main() {

printf("Welcome to the LinuxHint!\n");

return 0;

}

Once pasted, save the file using the “CTRL+S” shortcut key and exit from the nano editor using “CTRL+X”.

Now, compile the file with the gcc compiler and save it in a new file using the command:

$ gcc MyCfile.c -o MyCfile

As we can see that there is no error and the file has been successfully compiled.

Run the C code to display the output:

$ ./MyCfile

The displayed message confirmed that the GCC compiler installed using build essential tools is working perfectly.

Conclusion

Execute the “sudo apt install build-essential” command and it will install all the necessary packages to install build-essential tools on Ubuntu 22.04. Build essential tools contain the dependencies tools of different packages and compilers. In this blog, we have explained the installation method of Build Essential tools and its usage on Ubuntu using the command line interface.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.