Installing the GCC Compiler on Ubuntu/Debian

Installing the GCC compiler is a very easy task on Debian. The APT package manager and the APT repository has everything ready for you. Let’s look at how we can install GCC on our Debian systems in a quick and easy way.

What Languages Can GCC Compiler Compile?

GCC compiler or the GNU C compiler, as the name suggests, is a program used to compile code written in the C or C++ languages. The compiler also allows us to compile other languages namely: Objective C and C++, Ada, and Fortran.

Installing the GCC Compiler

If you’re working with any of the languages above, let’s get to installing the compiler right away. Now the thing with most Linux distributions is that they come pre-installed with the GCC compiler. Let’s verify if you have the compiler installed.

Verify if the GCC compiler is installed

Open up your terminal and type gcc --version. If you get the GCC version as your output, you can skip this tutorial and go one to read our other tutorials like the one we recently wrote on installing the latest VirtualBox on Debian.

But if you get an output like the one below, continue reading this tutorial because you don’t have the GCC compiler installed.

GCC Not Installed Output
GCC Not Installed Output

Using the APT package manager to install GCC

Let’s run an apt update to start with here. Once done we’ll install the GCC compiler.

root@HowLinux:~# apt update
Apt Update
Apt Update

You can now install one of the two packages. If you want to ONLY install GCC, then go ahead and run the command below:

root@HowLinux:~# apt install gcc

But there are certain dependencies, and also extra packages that may be required while compiling programs. The build-essential package is a more complete package that has additional libraries and the g++ compiler in addition to the GCC compiler for compiling code. In this tutorial, I’ll go ahead and install the build-essential package.

root@HowLinux:~# apt instlal build-essential
Installing Build Essential Package
Installing Build Essential Package

Hit enter at this prompt and continue. Once installed we can verify our installation again.

Checking the Installed Version of GCC

Like we did in step one to verify if GCC is installed, we’ll run the same command again.

root@HowLinux:~# gcc --version
Gcc Version Check
GCC Version Check


Great! We’ve successfully installed the GCC compiler on Debian with the build-essential package. To compile any code now, run gcc -c example.c -o output-file-name. If you also know Python, have a look at our tutorial about installing the latest version of Python on your Debian system.