How to Install GCC on Ubuntu 24.10

GCC is a toolchain that compiles code, links it with any library dependencies, converts that code to assembly, and then prepares executable files.

The default Ubuntu repositories contain a meta-package named “build-essential” that includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software.

Update System

 apt update
 apt install build-essential

Install the GCC package dependencies.

 apt-get install manpages-dev

Output:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
manpages-dev is already the newest version (6.8-2).
manpages-dev set to manually installed.

Check the GCC version using the below command,

 gcc --version

Output:

root@server:~#  gcc --version
gcc (Ubuntu 14.2.0-4ubuntu2) 14.2.0
Copyright (C) 2024 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.

That’s it. GCC tools and libraries have been installed on your Ubuntu system.

Compiling a Hello World Example

Compiling a basic C or C++ program using GCC is pretty easy. For example, let’s create a Hello World C program. Save the following code as hello.c text file:

nano hello.c
// hello.c
#include <stdio.h>

int main() {
    printf("Hello, world!\n");
    return 0;
}

Save the file and compile it into an executable,

gcc -o hello hello.c 
./hello 
Hello, world!

Done.


CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME for 10% off!

1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month

Available Locations: LAX | MIA | ATL | FRA | AMS