Site icon DesignLinux

How to Install GCC Compiler on Debian 11

How to Install Gcc on Debian 11

GCC stands for GNU Compiler Collection. It is an open-source collection of compilers and libraries. It includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D programming languages. GCC was originally written as the compiler for the GNU operating system. This guide explains how to install GCC compiler on Debian 11 Bullseye. It’s same procedure to install for Debian-based distros.

Perform the following steps to install GCC on Debian 11:

Step 1 – Prerequisites

Before you start installation, you must be login in as a user with sudo privileges.

Step 2 – Install GCC on Debian

A build-essential package that contains the GCC compiler and other libraries and utilities which required for compiling software. By default, build-essential package is included in default Debian repositories.

At first, to update the package list use the following command:

sudo apt update

Execute the bellow given command to install the build-required package.

sudo apt install build-essential

Now the GCC compiler is installed successfully. To check the GCC version issue the following command:

gcc --version

GCC version in output will different and depends when you installing. Output should look like this:

gcc (Debian 10.2.1-6) 10.2.1
Copyright (C) 2020 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.

Step 3 – Compile a sample Program

It is very easy to compile C or C++ program using GCC. Let’s create and example, we will print simple text “Welcome GCC!”. Type following lines using your favorite text editor and create a new file.

nano test.c
#include <stdio.h>
int main()
{
  printf ("Welcome GCC!\n");
  return 0;
}

Save the file and run below command to compile it make executable:

gcc test.c -o test

You can see that, a new binary file test has been created in your current working directory. To execute the program run:

./test

You will get output as following:

Welcome GCC!

Conclusion

You learned how to install GCC on your Debian 11 bullseye. You can get more information about GCC, visit the official GCC Documentation.

If you have any question or feedback, please leave a comment below.

Exit mobile version