How to Install GCC on Ubuntu 22.04

How to Install GCC on Ubuntu 22.04

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.

Install and use GCC on ubuntu 22.04; Through this tutorial, we will learn how to install and Use GCC compiler on Linux ubuntu 22.04 system.

Install GCC on Ubuntu 22.04 Terminal

Steps to install and use GCC in ubuntu 22.04 using terminal or command line:

  • Step 1 – Update System Dependencies
  • Step 2 – Install GCC
  • Step 3 – Verify GCC Installation
  • Step 4 – Create a C program in Run In GCC

Step 1 – Update System Dependencies

First of all, Open your terminal or command line and execute the following command into it to update system dependencies:

sudo apt update

Step 2 – Install GCC

Then install gcc in ubuntu system using the following command:

sudo apt install build-essential

If you want to install the latest gcc version 12 in Ubuntu 22.04, so use the following command for that:

sudo apt install gcc-12

Step 3 – Verify GCC Installation

Use the following command on command line to verify gcc installation on ubuntu system:

gcc --version

Step 4 – Create a C program in Run In GCC

Once the gcc installation has been done, Then create a simple hello world C program in nano editor and saved the file as helloworld.c.

#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}

Save this file and convert this into an executable one.

gcc -o helloworld helloworld.c

The above given command will generate a binary file by the name “helloworld” in the same directory. Execute the program using the following command on command line:

./helloworld

The C program was executed successfully.

Conclusion

Through this tutorial, we have learned how to install and Use the GCC compiler on Linux ubuntu 22.04 system.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *