How To Install cpp on CentOS 8

cpp is The C Preprocessor

Introduction

In this tutorial we learn how to install cpp on CentOS 8.

What is cpp

Cpp is the GNU C-Compatible Compiler Preprocessor. Cpp is a macro processor which is used automatically by the C compiler to transform your program before actual compilation. It is called a macro processor because it allows you to define macros, abbreviations for longer constructs. The C preprocessor provides four separate functionalities inclusion of header files (files of declarations that can be substituted into your program); macro expansion (you can define macros, and the C preprocessor will replace the macros with their definitions throughout the program); conditional compilation (using special preprocessing directives, you can include or exclude parts of the program according to various conditions); and line control (if you use a program to combine or rearrange source files into an intermediate file which is then compiled, you can use line control to inform the compiler about where each source line originated). You should install this package if you are a C programmer and you use macros.

We can use yum or dnf to install cpp on CentOS 8. In this tutorial we discuss both methods but you only need to choose one of method to install cpp.

Install cpp on CentOS 8 Using dnf

Update yum database with dnf using the following command.

sudo dnf makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install cpp using dnf by running the following command:

sudo dnf -y install cpp

Install cpp on CentOS 8 Using yum

Update yum database with yum using the following command.

sudo yum makecache --refresh

The output should look something like this:

CentOS Linux 8 - AppStream                                       43 kB/s | 4.3 kB     00:00    
CentOS Linux 8 - BaseOS                                          65 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - ContinuousRelease                               43 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - Extras                                          23 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - FastTrack                                       40 kB/s | 3.0 kB     00:00    
CentOS Linux 8 - HighAvailability                                36 kB/s | 3.9 kB     00:00    
CentOS Linux 8 - Plus                                            24 kB/s | 1.5 kB     00:00    
CentOS Linux 8 - PowerTools                                      50 kB/s | 4.3 kB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64           13 kB/s | 9.2 kB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                   24 kB/s | 8.5 kB     00:00    
Metadata cache created.

After updating yum database, We can install cpp using yum by running the following command:

sudo yum -y install cpp

How To Uninstall cpp on CentOS 8

To uninstall only the cpp package we can use the following command:

sudo dnf remove cpp

cpp Package Contents on CentOS 8

/usr/bin/cpp
/usr/lib/.build-id
/usr/lib/.build-id/80
/usr/lib/.build-id/80/773dabf5f6a697c94721e49e2b1e4fa44175e9
/usr/lib/.build-id/89
/usr/lib/.build-id/89/5ce7f243a48c00321eefa8aafc57d49b1c8db4
/usr/lib/cpp
/usr/libexec/gcc
/usr/libexec/gcc/x86_64-redhat-linux
/usr/libexec/gcc/x86_64-redhat-linux/8
/usr/libexec/gcc/x86_64-redhat-linux/8/cc1
/usr/share/info/cpp.info.gz
/usr/share/info/cppinternals.info.gz
/usr/share/locale/be/LC_MESSAGES/cpplib.mo
/usr/share/locale/ca/LC_MESSAGES/cpplib.mo
/usr/share/locale/da/LC_MESSAGES/cpplib.mo
/usr/share/locale/de/LC_MESSAGES/cpplib.mo
/usr/share/locale/el/LC_MESSAGES/cpplib.mo
/usr/share/locale/eo/LC_MESSAGES/cpplib.mo
/usr/share/locale/es/LC_MESSAGES/cpplib.mo
/usr/share/locale/fi/LC_MESSAGES/cpplib.mo
/usr/share/locale/fr/LC_MESSAGES/cpplib.mo
/usr/share/locale/id/LC_MESSAGES/cpplib.mo
/usr/share/locale/ja/LC_MESSAGES/cpplib.mo
/usr/share/locale/nl/LC_MESSAGES/cpplib.mo
/usr/share/locale/pt_BR/LC_MESSAGES/cpplib.mo
/usr/share/locale/ru/LC_MESSAGES/cpplib.mo
/usr/share/locale/sr/LC_MESSAGES/cpplib.mo
/usr/share/locale/sv/LC_MESSAGES/cpplib.mo
/usr/share/locale/tr/LC_MESSAGES/cpplib.mo
/usr/share/locale/uk/LC_MESSAGES/cpplib.mo
/usr/share/locale/vi/LC_MESSAGES/cpplib.mo
/usr/share/locale/zh_CN/LC_MESSAGES/cpplib.mo
/usr/share/locale/zh_TW/LC_MESSAGES/cpplib.mo
/usr/share/man/man1/cpp.1.gz

References

Summary

In this tutorial we learn how to install cpp on CentOS 8 using yum and dnf.