How to Install GCC (Development Tools) on CentOS 8
2 min read
The GNU Compiler Collection (GCC) is a collection of compilers and libraries for C, C++, Objective-C, Fortran, Ada, Go , and D, programming languages. A lot of open-source projects, including the Linux kernel and GNU tools, are compiled using GCC.
This article describes how to install GCC on CentOS 8.
Installing GCC on CentOS
The default CentOS repositories contain a package group named “Development Tools” that includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software.
To install the Development Tools packages, run the following command as root or user with sudo privileges :
sudo dnf group install "Development Tools"
The command installs a lot of packages, including
You may also want to install the manual pages about using GNU/Linux for development:
sudo dnf install man-pages
Validate that the GCC compiler is successfully installed by using the
gcc --version command which prints the GCC version:
The default version of GCC available in the CentOS 8 repositories is
gcc (GCC) 8.3.1 20190507 (Red Hat 8.3.1-4)
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.
That’s it. GCC has been installed on your CentOS system, and you can start using it.
Compiling a Hello World Example
In this section, we’ll compile a basic C program using GCC. Open your text editor and create the following file:
printf ("Hello World!\n");
Save the file and compile it into an executable by running:
gcc hello.c -o hello
A binary file named
hello will be created in the same directory where you run the command.
The program will output:
We’ve shown you how to installed GCC on CentOS 8. You can now visit the official GCC Documentation page and learn how to use GCC and G++ to compile your C and C++ programs.
If you hit a problem or have feedback, leave a comment below.