Skip to main content
AmigoFish

How to Install GCC and G++ Compiler on Ubuntu 26.04 LTS | C/C++ Setup

From ProgrammingKnowledge · · 6 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.

If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.

Watch on YouTube

Not rated yet

Description

# How to Install GCC and G++ Compiler on Ubuntu 26.04 LTS (Linux) | Complete Guide

In this complete beginner-friendly tutorial, you'll learn **how to install the GCC and G++ compilers on Ubuntu 26.04 LTS Linux**. GCC is the GNU Compiler Collection and provides the standard C compiler on Ubuntu, while G++ is the GNU C++ compiler. Ubuntu's official developer documentation recommends installing the `gcc` and `g++` packages through APT.

We'll also show you how to install the **Build Essential** package, which is often the easiest option when setting up a complete C/C++ development environment. On Ubuntu 26.04 LTS, `build-essential` depends on GCC, G++, the C development libraries, and `make`.

## What You'll Learn

In this tutorial, we'll cover:

* What is GCC? * What is G++? * GCC vs G++ * Why you need a C/C++ compiler * Installing GCC on Ubuntu 26.04 LTS * Installing G++ on Ubuntu 26.04 LTS * Installing the `build-essential` package * Checking GCC and G++ versions * Creating your first C program * Compiling a C program with GCC * Creating your first C++ program * Compiling a C++ program with G++ * Running compiled programs * Understanding compiler errors * Troubleshooting GCC/G++ installation problems

## Step 1: Open the Ubuntu Terminal

Start by opening the Terminal application.

You can use the keyboard shortcut:

## GCC vs G++

It's important to understand the difference:

| Compiler | Primary use | | ----------------- | --------------------------------------- | | `gcc` | C and GNU compiler collection | | `g++` | C++ compilation | | `make` | Automates compilation/build processes | | `build-essential` | Installs the core development toolchain |

For a C program, you'll normally use:

```bash gcc program.c -o program ```

For a C++ program:

```bash g++ program.cpp -o program ```

## Step 10: Compile With Warnings

When developing software, it's a good idea to enable compiler warnings.

For C:

```bash gcc -Wall -Wextra hello.c -o hello ```

For C++:

```bash g++ -Wall -Wextra hello.cpp -o hello-cpp ```

Warnings can help identify potential problems in your code before they become bugs.

## Step 11: Check the Build Tool

If you installed `build-essential`, verify that `make` is available:

```bash make --version ```

The `make` utility is commonly used by Linux projects to automate compiling and linking multiple source files.

## Troubleshooting Common Problems

### `gcc: command not found`

If you receive:

```text gcc: command not found ```

install GCC:

```bash sudo apt update sudo apt install gcc ```

### `g++: command not found`

Install G++:

```bash sudo apt update sudo apt install g++ ```

Or install the complete development toolchain:

```bash sudo apt install build-essential ```

### APT cannot find the package

First refresh your package lists:

```bash sudo apt update ```

Then try:

```bash sudo apt install build-essential ```

If you're running Ubuntu 26.04 LTS, `build-essential` is available in the official Ubuntu repositories.

### Compilation errors

If GCC or G++ is installed but your program doesn't compile, the problem may be with the source code rather than the compiler installation.

Read the error message carefully and check:

* Missing headers * Syntax errors * Missing semicolons * Incorrect function names * Incorrect library references * Incorrect compiler options

## Final Verification

You can quickly verify the complete environment with:

```bash gcc --version g++ --version make --version ```

If all three commands return version information, your basic C/C++ development environment is ready.

By the end of this tutorial, you'll know **how to install GCC, G++, and Build Essential on Ubuntu 26.04 LTS, verify the installation, compile C and C++ programs, and run your first applications from the Linux Terminal**.

This setup provides a solid foundation for learning **C, C++, Linux programming, system programming, embedded development, competitive programming, and software development**.

If you…

Back to ProgrammingKnowledge · Report a problem