How To Install cpp on CentOS 7

In this tutorial we learn how to install cpp on CentOS 7. cpp is The C Preprocessor

Introduction

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

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 7. In this tutorial we discuss both methods but you only need to choose one of method to install cpp.

Install cpp on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

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

sudo yum -y install cpp

Install cpp on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

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

sudo dnf -y install cpp

How To Uninstall cpp on CentOS 7

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

sudo dnf remove cpp

References

Summary

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