February 9, 2022

How to Install GCC on Ubuntu

How to Install GCC on Ubuntu

GCC is one of the favorite tools used by developers working on the Linux platform. It serves as an integration of several compilers for popular programming languages such as Java, C, C++, Fortran, and many more. If you are beginning your journey with Linux, what better option there is than Ubuntu. Ubuntu is the most famous of all Linux distribution out there. It is known to be easy to learn while not compromising on the features front of things. So, if you are in need to know how to install GCC on your Ubuntu system, this article is the perfect place to start. We will explore how to download and install GCC on Ubuntu in the sections below. But before that let’s know more about GCC.

How to Install GCC on Ubuntu

How to Install GCC on Ubuntu

GCC (GNU Compiler Collection) is a set of tools for compiling source code from various programming languages into binaries, executables, or libraries. GCC is a command-line compiler that may be installed on Ubuntu.

  • The GCC compiler, as well as many libraries and other tools necessary for generating applications, is included in the default Ubuntu repository as build-essential
  • C, C++, Java, Objective-C, Go, Fortran, Ada, and more programming languages are supported by GCC.
  • Many open-source projects, including the GNU utilities and the Linux kernel, require GCC to build their code.

This tutorial will show you how to set up the GCC compiler on Ubuntu 18.04. We’ll teach you how to install the stable version of the distribution as well as the most recent version of GCC. The steps are the same for Ubuntu 16.04 and any Ubuntu-based distribution, such as Kubuntu, Linux Mint, and Elementary OS.

Note: You must be logged in as root or a user with sudo privileges to create new repositories and install packages on your Ubuntu system.

Method 1: Through Ubuntu Terminal

To set up GCC on Ubuntu, you’ll need to download and install the build-essential package. Open a terminal window to download gcc ubuntu. Follow the given steps to install GCC on Ubuntu through the Terminal.

Option 1: Install a Particular GCC Version

1. Press Ctrl + Alt + T keys together to launch a terminal window on the Desktop.

Note: Alternatively, go to the app menu and search for Terminal.

Ubuntu linux terminal. How to Install GCC on Ubuntu

2. Use the install command below to install the build-essential package on Ubuntu once the terminal window is open.

sudo apt install build-essential

Note: The Sudo command prompts you for your password. Users can use this command to run a single task as root.

ubuntu linux terminal command to install build essential package

3. Ubuntu will prompt you for your password. Enter your user password to continue.

4. The terminal prompt will gather all dependencies for the build-essential package once you’ve supplied your password. Ubuntu will next ask you whether or not you wish to install the package. To proceed, press the Y key. When you hit the Y key, Ubuntu will begin installing GCC on your machine.

5. This procedure should take no more than a few minutes. With the man gcc command, you may browse the GCC documentation after the procedure is complete.

Also Read: Top 14 Best Graphics Card for Linux

Option 2: Install Multiple GCC Versions

While most Ubuntu users will be satisfied with the build-essential package because it contains GCC 10, it is not the only version of GCC available. Support for additional languages, improved performance, and expanded functionality are all included in newer versions of the GCC compiler. You have the option of installing various versions of GCC on Ubuntu. Here’s how to download gcc ubuntu.

1. First, on the Ubuntu desktop, open a terminal window.

2. Once it’s open, use the following command to search the Ubuntu software repositories for available GCC packages:

apt search gcc

apt search gcc command in ubuntu linux terminal. How to Install GCC on Ubuntu

3. Search through the prompt for the GCC version you want to install on Ubuntu. GCC 7, GCC 8, 9, and 10 will be available for installation.

4. Install GCC using the apt install instructions below once you’ve found the version you want to install on your Ubuntu PC. gcc-7, gcc-8, gcc-9, and gcc-10 are GCC packages.

5. To install the GCC version 7 on Ubuntu.

sudo apt install gcc-7 g++-7

execute command to install gcc version 7 in ubuntu linux terminal

6. To install GCC version 8 on Ubuntu.

sudo apt install gcc-8 g++-8

execute command to install gcc version 8 in ubuntu linux terminal. How to Install GCC on Ubuntu

7. To install the GCC version 9 on Ubuntu.

sudo apt install gcc-9 g++-9

execute command to install gcc version 9 in ubuntu linux terminal

8. While installing the build-essential package is strongly recommended for getting GCC 10 to operate on Ubuntu, it isn’t the only option to do it. Installing the gcc-10 and g++-10 packages will also install GCC 10.

sudo apt install gcc-10 g++-10 

execute command to install gcc version 10 in ubuntu linux terminal. How to Install GCC on Ubuntu

Also Read: 20 Best Lightweight Linux Distros of 2022

Method 2: Through Synaptic Package Manager

If you don’t want to use the console to install GCC on Ubuntu, you may use the Synaptic Package Manager instead to download GCC in ubuntu.

Option 1: Install a Particular GCC Version

Follow these steps to install GCC through Synaptic Package Manager.

1. To begin, make sure Synaptic is installed. To get Synaptic, go to the Ubuntu Software program and search for Synaptic, then install it.

install synaptic package manager from ubuntu software

2. Open the Synaptic Package Manager by searching for it in the app menu once it has been installed.

open synaptic package manager from the all applications menu ubuntu linux

3. Then, in the top-right corner of the screen, look for the search button.

4. To display the search results, pick the Synaptic search button and input build-essential followed by the Enter key.

search build essential in snaptic package manager ubuntu linux

5. Look through Synaptic search results for build-essential.

6. Once you’ve identified it, right-click on it and choose the Designate for installation option to mark the build-essential package for Synaptic installation.

right click on build essential and select Mark for installation in Snaptic Package Manager Ubuntu Linux

7. In Synaptic, locate the Apply button and click it to begin the GCC installation on Ubuntu.

click on Apply button in Snaptic Package Manager Ubuntu Linux

Also Read: How To Install Linux Bash Shell On Windows 10

Option 2: Install Multiple GCC Versions 

To install a GCC version other than the one supplied with the build-essential package in Ubuntu, perform the steps below.

1. First, open Synaptic Package Manager.

2. Once Synaptic is open, click on the search button.

3. Then select one of the products from the list below and enter it into the search box.

  • GCC 7: gcc-7, g++-7
  • GCC 8: gcc-8, g++-8
  • GCC 9: gcc-9, g++-9
  • GCC 10: gcc-10, g++-10

4. To install the GCC package(s) you’ve found in Synaptic, right-click on it and pick the Apply button.

select gcc 7 and click on apply button in synaptic package manager Ubuntu linux

5. Repeat this procedure as needed to install as many versions of GCC as you like on Ubuntu.

Frequently Asked Questions (FAQs)

Q1. Is GCC already installed on your Ubuntu?

Ans. On all Ubuntu desktop variants, the GCC package is installed by default.

Q2. Which command is used to install GCC?

Ans. Install GNI C/C++ (GCC) and needed libs using the up2date command, yum command, or apt-get command, depending on your Linux distro.

Q3. What is the purpose of Ubuntu?

Ans. Ubuntu has everything you’ll need to manage your company, school, house, or business. All of the main software, like an office suite, browsers, email, and media apps, are pre-installed, and the Ubuntu Software Centre has hundreds of additional games and applications.


We hope this article will prove to be helpful in finding out how to install gcc Ubuntu. You can find many more articles related to tech on our website. If you have any suggestions or feedback regarding this article, you can reach out to us in the comment section below.