How to Install GCC on Debian 10

GCC, the GNU Compiler Collection is a compiler system developed to support various programming languages. GCC is the standard compiler for most projects related to GNU and Linux, including the Linux kernel.

Installing GCC on Debian

Debian repositories contain build-essential package which contains the GCC compiler, g++ and make

Update an existing system by running following command

apt upgrade

apt install build-essential

If you want to install the manual page for GCC, run the below command,

apt-get install manpages-dev

After installing, to verify that GCC is successfully installed by checking gcc version,

gcc --version

Output:

root@vps:~# gcc --version
gcc (Debian 8.3.0-6) 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.

Compiling a Hello World Example

Create a basic C code source, eg: let's create hello world C program and open hello.c text file,

nano hello.c

Add the following code to hello.c file

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

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

Compile it into an executable and execute the hello program by running following commands,

gcc hello.c -o hello

./hello

Output:

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