Skip to content

How to install GCC in Ubuntu?

One of the best parts about using Linux, especially for developers, is the ability to quickly download and install required tools and utilities with a single command. This helps save time and effort when you’re either setting up a new development environment or starting a new project.

In this article, we’re taking a look at how to install GCC on Ubuntu.

Also read: How to install OpenCV in Ubuntu?


Installing GCC on Ubuntu 20.04

GCC stands for GNU Compiler Collection. It is a collection of different compilers and some libraries for C, C++, Objective-C, Ada, Go, Fortran and D. The tool is used to compile many open-source projects, including the Linux kernel itself. 

Installing GCC on Ubuntu is rather easy. Here’s how.

sudo apt update
sudo apt install build-essential

The command above will install gcc, g++ and make.

By default, the Ubuntu 20.04 repositories install GCC version 9.3.0. If you want to install a different version, mention the version number after the install command. For example, to install multiple versions of GCC, use this command.

sudo apt install gcc-8 g++-8 gcc-9 g++-9 gcc-10 g++-10

In such cases, the default version of the installation would be the latest version installed. While you’ll have to use other versions by mentioning their version names.

You can check GCC versions installed on your machine using this command.

gcc --version

Using GCC to compile scripts

As mentioned above, GCC is used to compile a lot of open-source projects. If you have a C/C++ program named program.c, you can compile it into an executable using GCC. Here’s how.

gcc program.c -o executable

The -o flag specifies the name of the executable file that will be generated. Now assuming your program compiled successfully, you can use the executable to run it in the terminal.

./executable

Also read: What is Kali Undercover and how to install it on Linux?

Hello There!

If you like what you read, please support our publication by sharing it with your friends, family and colleagues. We're an ad-supported publication. So, if you're running an Adblocker, we humbly request you to whitelist us.

Share on facebook
Share on whatsapp
Share on twitter
Share on reddit
Share on linkedin
Share on pocket
Share on pinterest
Share on telegram
Share on stumbleupon
Share on digg
Share on tumblr
Share on email
Share on skype
Share on xing
Share on vk
Share on odnoklassniki
Share on mix








>