Powered by Blogger.

Tuesday, 24 January 2023

Tag:

How to install G++ the C++ compiler on Ubuntu 18.04 Bionic Beaver Linux


 

How to install G++ the C++ compiler on Ubuntu 18.04 Bionic Beaver Linux






Objective

The objective is to install G++ the C++ compiler on Ubuntu 18.04 Bionic Beaver

Operating System and Software Versions

  • Operating System: – Ubuntu 18.04 Bionic Beaver

Requirements

Privileged access to your Ubuntu System as root or via sudo command is required.

Conventions

  • # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – requires given linux commands to be executed as a regular non-privileged user

Other Versions of this Tutorial

Ubuntu 20.04 (Focal Fossa)

Instructions

Install GCC

The following linux command will install gcc compiler on on Ubuntu 18.04 Bionic Beaver. Open up terminal and enter:

$ sudo apt install g++

Install build-essential

Another way to install g++ compiler is to install it as part of build-essential package. Additionally the build-essential package will also install additional libraries as well as gcc compiler. In most cases or if unsure this is exactly what you need:

$ sudo apt install build-essential


Check G++ version

Confirm your installation by checking for GCC version:

$ g++ --version
g++ (Ubuntu 7.2.0-18ubuntu2) 7.2.0
Copyright (C) 2017 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.

C Hello World

Compile a simple C++ “Hello World” code:

#include <iostream>
using namespace std;

int main() 
{
    cout << "Hello, World!";
    return 0;
}

Save the above code within hello.cc file, compile and execute it:

$ g++ -o hello hello.cc 
$ ./hello 
Hello, World!

About Code Tutorial

Hi, My Name is Hafeez. I am a webdesigner, blogspot developer and UI designer. I am a certified Themeforest top contributor and popular at JavaScript engineers. We have a team of professinal programmers, developers work together and make unique blogger templates.

0 comments:

Post a Comment