• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install GCC on Ubuntu 22.04

Written by Admin, Updated On January 7, 2023
gcc, ubuntu
How to Install GCC on Ubuntu 22.04

GCC or GNU Compiler Collection is a compiler system for C, C++, Objective-C, Objective-C++, Fortran, Ada, D, Go, and BRIG (HSAIL) programming languages. These compilers can be on used on Windows, Linux and many other operating systems. It’s produced by the GNU Project and the current version is GCC 12.2. In this article we will explain how to install GCC on Ubuntu 22.04.

How to install GCC on Ubuntu 22.04#

Perform the following steps to install GCC on Ubuntu 22.04 system:

Step 1 – Update System

At first, you have to update the system before start installation of GCC. It will update all the dependent packages. Run the below given command to update system:

sudo apt update

Step 2 – Install GCC

After that, you should install the build-essential which consists of packages of GCC. The build-essential package is available in default Ubuntu repositories. It includes GNU compiler collection and entire development package.

Issue the following command to install the Development Tools packages as root or user with sudo privileges:

sudo apt install build-essential

Step 3 – Verify Installation

Once the installation is complete, you can verify the version by typing:

gcc --version

It should print the following output:

gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

At this stage, GCC tools and libraries are installed on your Ubuntu system.

Step 4 – Test Compiling

To test a compiling, Let’s create a small program. Open your text editor and create the following file:

nano welcome.c
#include <stdio.h>
 
int main() {
    printf("You're welcome!\n");
    return 0;
}

Save it as welcome.c and compile it using following command:

gcc -o welcome welcome.c

The above command will create a binary file named welcome in the current working directory.

To execute program, type:

./welcome

It will show output as following:

You're welcome!

Conclusion#

This tutorial covers how to install GCC on Ubuntu 22.04 system and how to create a C or C++ program using GCC.

To know more about to use GCC and G++ to compile your C and C++ programs visit the official GCC Documentation.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Apache Cassandra on Debian 11
Next Article   How to Install Go on Ubuntu 22.04

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook