How to install C++ on Linux – Step by Step Guide

Linux is an excellent platform for programming in various languages, as it provides a handy and coding-friendly environment. In this C++ tutorial, we will discuss how to install the C++ setup in various Linux distros. In order to compile the C++ programs in Linux distributions like Ubuntu, Red Hat, Fedora, Arch Linux, etc we need the gcc a GNU C and C++ compiler installed in our system.

Let’s see how we can install the gcc compiler in our Linux system by simple commands step by step.

Installing C++ in various Linux Distros

Methods to installing gcc via different package managers:

apt-get package manager:

The package manager is used in Linux distributions like Debian, Ubuntu, Linux Mint, Deepin, etc.

Step1:Open the terminal emulator by pressing Ctrl+Alt+T.

Step2:Install the gcc compiler tool by using apt-get, make sure to use sudo for root permission.

sudo apt-get install gcc

Step3:You would get a message “Do you want to continue?” during the installation process, press ‘y‘ in order to continue the process.

Step4:Check the version of the gcc to make sure the compiler is installed properly in our system.

gcc --version

Output:

apt-get c++ gcc

pacman package manager:

The package manager is used in Linux distributions like Arch Linux, Manjaro, ArkOS, EndeavourOS, etc.

Step1: Open the terminal emulator by pressing Ctrl+Alt+T.

Step2: Install the gcc compiler tool by using pacman, make sure to use sudo for root permission.

sudo pacman -S gcc

Step3: You would get a message “Do you want to continue?” during the installation process, press ‘y‘ in order to continue the process.

Step4:Check the version of the g++ to make sure the compiler is installed properly in our system.

g++ --version

Output:

pacman package manager

dnf package manager:

The package manager is used in Linux distributions like RedHat Enterprise Linux, Fedora, CentOS, Oracle Enterprise Linux, SUSE, etc.

Step1: Open the terminal emulator by pressing Ctrl+Alt+T.

Step2: Install the gcc compiler tool by using dnf, make sure to use sudo for root permission.

sudo dnf install gcc

Step3: You would get a message “Do you want to continue?” during the installation process, press ‘y‘ in order to continue the process.

Step4: Check the version of the gcc to make sure the compiler is installed properly in our system.

gcc --version

Output:

dnf package manager:dnf package manager

dnf package manager:

Hope you enjoy learning today’s tutorial and gained knowledge of how to install C++ in a Linux system.

You can also read, How to uninstall C++ on Linux

Leave a Reply

Your email address will not be published. Required fields are marked *