Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install GCC on Ubuntu 22.04 - DesignLinux

Nov 18 2022
designlinux 0 Comments
how-to-install-gcc-compiler-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.

Related

Tags: gcc, ubuntu

How to Save a File in Vi / Vim Editor in Linux

Prev Post

How to Install Go on Ubuntu 22.04

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 1
  • 724
  • 610,083

DesignLinux.com © All rights reserved

Go to mobile version