The GNU Compiler Collection (GCC) is a collection of compilers and libraries for the C, C ++, Objective-C, Fortran, Ada, Go, and D programming languages. Several open source projects including GNU Tools and the Linux kernel are bundled with GCC.
This tutorial covers the steps required to install the GCC translator on CentOS 8.
Install GCC on CentOS 8
The default CentOS repository contains a package group named “Development toolsWhich includes the GNU Compiler and GNU Debugger and Development libraries Other as well as tools for Aggregation Software.
To install the package Development tools, Run the following command as root or sudo privileged user:
sudo dnf group install "Development Tools"
The command installs many packages, including gcc
And the g++
And the make
.
You may also want to install manual pages about using GNU / Linux for development:
sudo dnf install man-pages
Verify that the GCC compiler has installed successfully using the command gcc --version
Which prints the Gulf version:
gcc --version
The default version of the GCC available in the CentOS 8 repository (at the time of writing) is 8.3.1
:
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.
At this point, GCC is now installed on your CentOS system.
An example of C language translation with GCC countries
Compiling a basic C or C ++ program using GCC is very easy. Open a text editor on the device using the commands nano
And create the following files:
nano hello.c
#include <stdio.h> int main () { printf ("Hello World!n>"); return 0; }
Save the file and translate the file hello.c
It is an executable file with the following command:
gcc hello.c -o hello
This will create a binary file called hello
In the same directory where you ran the command.
Run the program Hi With:
./hello.
The program will output:
Hello World!
Conclusion
You have successfully installed GCC on Debian 10. You can visit the official GCC documentation page and learn how to use GCC and G ++ to translate C and C ++ programs.
.
Originally posted 2020-11-17 18:46:37.