Categories: TutorialsUbuntu

A Comprehensive Guide to Installing GCC on Ubuntu 22.04

The GNU Compiler Collection, commonly known as GCC, is a key tool in software development. It supports a wide range of programming languages and has played a significant role in the growth of open-source software.

This guide will walk you through installing GCC on Ubuntu 22.04, also known as Jammy Jellyfish.

Overview of GCC

GCC is available across various operating systems, including Linux, Windows, and macOS. It supports multiple programming languages such as C, C++, Objective-C, Fortran, and even newer languages like Go. With GCC, developers can utilize different code optimization levels to ensure their applications are efficient and resource-conservative.

GCC also offers language extensions that allow developers to create powerful applications. The GCC ecosystem is supported by a dynamic community that continuously contributes to keeping GCC up-to-date with emerging language standards.

Sponsored

Read: How to run Python on Ubuntu 20.04

Installing GCC on Ubuntu 22.04

Before we begin the installation process, it’s essential to update your system to ensure all existing packages are up-to-date. This helps avoid any conflicts during the installation.

sudo apt update

sudo apt upgrade

We will first install either the Ubuntu GCC package directly or the build-essential package which contains GCC and other essential development tools such as make, g++, and dpkg-dev.

sudo apt install gcc

or

sudo apt install build-essential

Read: How to Install Java on Ubuntu

Once installed, you can verify the installation and check the version using the following command.

gcc –version

Sponsored

Creating a C Program on Ubuntu 22.04

After the installation, it’s time to check if the compiler is functioning as expected. This can be done by creating a basic C program. For example, we can create a straightforward “this is net2” C program using the nano editor and save the file as thisisnet2.c.

int main() {

printf(“thisisnet2n”);

return 0;

}

Save this document and transform it into an executable file.

gcc -o thisisnet2 thisisnet2.c

This command will create a binary file named ‘thisisnet2’ in the current directory. To run the program, use the following command:

The C program has been executed without any issues. GCC has been installed successfully on your Ubuntu 22.04 system.

Read: How to Install MongoDB on Ubuntu 22.04 

Conclusion

GCC is an invaluable tool for developers working on Linux distributions. It aids in building, refining, and debugging applications. Its adaptability and expansive language support make it an essential asset in software development.

 

The post A Comprehensive Guide to Installing GCC on Ubuntu 22.04 appeared first on net2.

Ubuntu Server Admin

Recent Posts

Canonical Releases Ubuntu 25.04 Plucky Puffin

The latest interim release of Ubuntu introduces “devpacks” for popular frameworks like Spring, along with…

2 days ago

Ubuntu 25.04 (Plucky Puffin) Released

Ubuntu 25.04, codenamed “Plucky Puffin”, is here. This release continues Ubuntu’s proud tradition of integrating…

3 days ago

Extended Security Maintenance for Ubuntu 20.04 (Focal Fossa) begins May 29, 2025

Ubuntu released its 20.04 (Focal Fossa) release 5 years ago, on March 23, 2020. As…

3 days ago

Ubuntu 20.04 LTS End Of Life – activate ESM to keep your fleet of devices secure and operational

Focal Fossa will reach the End of Standard Support in May 2025, also known as…

4 days ago

Ubuntu MATE 25.04 Release Notes

Ubuntu MATE 25.04 is ready to soar! 🪽 Celebrating our 10th anniversary as an official…

4 days ago

Ubuntu Weekly Newsletter Issue 887

Welcome to the Ubuntu Weekly Newsletter, Issue 887 for the week of April 6 –…

6 days ago