How To Install GCC on Debian 11

Install GCC on Debian 11

In this tutorial, we will show you how to install GCC on Debian 11. For those of you who didn’t know, GCC (GNU Compiler Collection) is a collection of tools used to compile different programming languages’ source code into binary, executables, or libraries. GCC supports a lot of programming languages like C, C++, Java, Objective-C, Go, Fortran, Ada, etc.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of GCC Compiler on a Debian 11 (Bullseye).

Prerequisites

  • A server running one of the following operating systems: Debian 10 or Debian 11.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install GCC on Debian 11 Bullseye

Step 1. Before we install any software, it’s important to make sure your system is up to date by running the following apt commands in the terminal:

sudo apt update
sudo apt upgrade
sudo apt install build-essential

Step 2. Installing GCC on Debian 11.

By default, GCC is available in the Debian base repositories and it can be easily installed using the APT package manager. To install GCC on your Debian 11 system, run the following command:

sudo apt install manpages-dev

Now check the installed GCC version using the following command:

gcc --version

Step 3. Compiling Hello World Using GCC.

Once successfully installed, now we create a basic C code source, for example: let’s create a hello world C program and open hello.c text file:

nano hello.c

Add the following line:

// hello.c
#include 

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

Save and close, then compile it and execute the hello program by running the following command below:

gcc hello.c -o hello
./hello

Output:

root@idroot.us:~# ./hello 
Hello, world!

Congratulations! You have successfully installed GCC. Thanks for using this tutorial for installing the latest version of GCC Compiler on Debian 11 Bullseye. For additional help or useful information, we recommend you check the official GCC website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!