Here’s how you can install them both on your machine.

Installing GCC on Linux

GCC, or the GNU Compiler Collection, has been around since the 1980s, predating Linux itself. Not only does it compile C programs, but also handles C++, Objective-C, Objective-C++, Fortran, ADA, and Go. A lot of open-source projects still rely on it, including the Linux kernel.

To install GCC along with the required C libraries on Debian and Ubuntu, install the build-essential package:

On Fedora and other RPM-based distros:

And on Arch Linux:

On any other distribution, you can usually search for “GCC” and you’ll find a package for your system. This goes for Clang as well.

To compile a simple C program, such as the famous “Hello, World!”, just go to the directory where you saved it and run the following command:

…where hello.c is the name of your program.

If the program is correct, GCC will output the compiled file as a.out in the current directory. To run it, type:

Installing Clang on Linux

The newer kid on the block is the Clang compiler, developed as a front to the LLVM compiler by Apple, ARM, Sony, AMD, and others. Apple uses it as the compiler for its Xcode development environment for macOS.

Clang aims for compatibility with GCC, while increasing performance. It’s popular because it’s licensed under the Apache 2.0 License, which doesn’t require developers to release their source code if they make modifications.

You can install Clang using your package manager. On Debian and Ubuntu, just install the clang package:

On Fedora/CentOS:

To install Clang on Arch-based distributions:

Compiling works the same as with GCC:

Now You Can Compile C Programs in Linux

Whether you’re just learning C or are an experienced C programmer, you can easily install two major C compilers for Linux—GCC and Clang.

If you want to explore C programming, here are some more tips on the language that will give you a headstart.