How To Install cppcheck on CentOS 8

cppcheck is Tool for static C/C++ code analysis

Introduction

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

What is cppcheck

Cppcheck is a static analysis tool for C/C++ code. Unlike C/C++ compilers and many other analysis tools it does not detect syntax errors in the code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. The goal is to detect only real errors in the code (i.e. have zero false positives).

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

Install cppcheck 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 cppcheck using dnf by running the following command:

sudo dnf -y install cppcheck

Install cppcheck 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 cppcheck using yum by running the following command:

sudo yum -y install cppcheck

How To Uninstall cppcheck on CentOS 8

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

sudo dnf remove cppcheck

cppcheck Package Contents on CentOS 8

/usr/bin/cppcheck
/usr/lib/.build-id
/usr/lib/.build-id/72
/usr/lib/.build-id/72/22154af6112a4125195bc978f6b814e56eafec
/usr/share/CppCheck
/usr/share/CppCheck/avr.cfg
/usr/share/CppCheck/bsd.cfg
/usr/share/CppCheck/cppcheck-lib.cfg
/usr/share/CppCheck/embedded_sql.cfg
/usr/share/CppCheck/gnu.cfg
/usr/share/CppCheck/gtk.cfg
/usr/share/CppCheck/lang
/usr/share/CppCheck/lang/cppcheck_de.qm
/usr/share/CppCheck/lang/cppcheck_es.qm
/usr/share/CppCheck/lang/cppcheck_fi.qm
/usr/share/CppCheck/lang/cppcheck_fr.qm
/usr/share/CppCheck/lang/cppcheck_it.qm
/usr/share/CppCheck/lang/cppcheck_ja.qm
/usr/share/CppCheck/lang/cppcheck_ko.qm
/usr/share/CppCheck/lang/cppcheck_nl.qm
/usr/share/CppCheck/lang/cppcheck_ru.qm
/usr/share/CppCheck/lang/cppcheck_sr.qm
/usr/share/CppCheck/lang/cppcheck_sv.qm
/usr/share/CppCheck/lang/cppcheck_zh_CN.qm
/usr/share/CppCheck/microsoft_sal.cfg
/usr/share/CppCheck/motif.cfg
/usr/share/CppCheck/posix.cfg
/usr/share/CppCheck/qt.cfg
/usr/share/CppCheck/sdl.cfg
/usr/share/CppCheck/sfml.cfg
/usr/share/CppCheck/std.cfg
/usr/share/CppCheck/windows.cfg
/usr/share/CppCheck/wxwidgets.cfg
/usr/share/doc/cppcheck
/usr/share/doc/cppcheck/AUTHORS
/usr/share/doc/cppcheck/COPYING
/usr/share/doc/cppcheck/manual.html
/usr/share/man/man1/cppcheck.1.gz

References

Summary

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