DebianLinuxTutorials

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, which stands for GNU Compiler Collection, is a powerful and versatile compiler system that plays a crucial role in programming and development on Debian-based systems. As an essential tool for compiling C, C++, and other programming languages, GCC is a must-have for any developer working on Debian 11.

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 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 user or 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. To guarantee a smooth installation process, it’s crucial to update your system to the latest stable version. Open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

These commands will fetch the latest package lists from the repositories and upgrade any outdated packages to their newest versions. Having an up-to-date system not only ensures compatibility with GCC but also helps maintain the security and stability of your Debian 11 installation.

Step 2. Installing GCC on Debian 11.

The simplest and most straightforward way to install GCC on Debian 11 is by using the build-essential package. This meta-package includes not only GCC but also G++ (the C++ compiler) and other essential development tools like make. To install build-essential, run the following command:

sudo apt install build-essential

Enter your sudo password when prompted and confirm the installation by pressing ‘Y’ when asked. The package manager will now download and install GCC, G++, and the required dependencies.

Once the installation is complete, you can verify that GCC is successfully installed by checking its version. Run 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!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button