
The GNU Compiler Collection (GCC) 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. In this article explains how to install the GCC compiler on Debian 10 Buster. It’s same procedure to install for Debian-based distros.
Step 1 – Prerequisites
Before you start installation, you must be logged 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, the default Debian repositories contain this build-essential
package.
First, update the package list.
sudo apt update
Run the below command to install build-essential package.
sudo apt install build-essential
At this, point GCC compiler is successfully installed, you can verify by checking gcc version
:
gcc --version
It should show output as below:
GCC version in output will different and depends when you installing.
gcc (Debian 8.3.0-1) 8.3.0 Copyright (C) 2018 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.
GCC version in output will different and depends when you installing.
Step 3 – Compile a sample Program
It’s very easy to compile c or c++ program using GCC. In this 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
It should show output as below:
Welcome GCC!
Conclusion
You learned how to install GCC on your Debian 10 Buster. You can get more information about GCC, visit the official GCC Documentation.
If you have any question or feedback, please leave a comment below.
Leave a Reply