How To Install GCC Compiler On Ubuntu?

GCC (GNU Compiler Collection) is a collection of tools used to compile different programming languages source code into binary, executables, or libraries. GCC supports a lot of programming languages like C, C++, Java, Objective-C, Go, Fortran, Ada, etc. A lot of open-source projects use the GCC to compile source code to binary. In this tutorial, we will learn how to install GCC compiler set in Ubuntu and compile sample C applications into binary.

Install GCC on Ubuntu

The GCC is provided with the gcc name in Ubuntu. This means the gcc package name is used to display details, install , update or remove GCC. First we will show information about the gcc package which provides basic information about this package like description, size and version.

apt show gcc
Package: gcc
Version: 4:10.2.0-1ubuntu1
Priority: optional
Build-Essential: yes
Section: devel
Source: gcc-defaults (1.189ubuntu1)
Origin: Ubuntu
Maintainer: Ubuntu Developers [email protected]
Original-Maintainer: Debian GCC Maintainers [email protected]
Installed-Size: 51,2 kB
Provides: c-compiler, gcc-x86-64-linux-gnu (= 4:10.2.0-1ubuntu1)
Depends: cpp (= 4:10.2.0-1ubuntu1), gcc-10 (>= 10.2.0-8~)
Recommends: libc6-dev | libc-dev
Suggests: gcc-multilib, make, manpages-dev, autoconf, automake, libtool, flex, bison, gdb, gcc-doc
Conflicts: gcc-doc (<< 1:2.95.3)
Task: ubuntu-mate-core, ubuntu-mate-desktop
Download-Size: 5.208 B
APT-Manual-Installed: yes
APT-Sources: groovy/main amd64 Packages
Description: GNU C compiler
 This is the GNU C compiler, a fairly portable optimizing compiler for C.
 This is a dependency package providing the default GNU C compiler.

We can install the GCC with the following apt command for Ubuntu, Debian, Mint etc. We also provide the sudo command for root privileges.

sudo apt install gcc

Check GCC Version

After the GCC installation is completed or at any time we can check the installed GCC version. The –version option is used to display the GCC version.

gcc --version
gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

Install GCC Build Essential and C++ Compiler on Ubuntu

GCC is very extensive tool set where there are a lot of extensions about it. The build essentials is a set of tools which provides extra libraries for GCC and also the C++ compiler named g++. The build essentials is named as build-essential and can be installed like below.

sudo apt install build-essential

Compile Example C Application

After installing the GCC we can check the installation and compile a sample C application.

#include <stdio.h>
int main()
   printf("Hello, LinuxTect!");
   return 0;

We will compile this C application with the GCC command. The -o option is used to specify the created binary name and the source file name.

gcc -o hello hello.c

Updating GCC on Ubuntu

The GCC is a very active project and updated regularly. In every update, new features and bug fixes are provided. The installed GCC can be easily updated in Ubuntu by using the “apt update” command like below.

sudo apt update gcc
READ  How To Create Groups In Linux?

Leave a Comment