Try   HackMD

Cppcheck Compilation and Installation Guide

contributed by < jasperlin1996 >

This page describes steps for compiling the Cppcheck from the source. Currently, Cppcheck 2.7 is the latest version.

Note

If you're using Manjaro (or any other Arch Linux distribution), the latest version of Cppcheck is available on pacman.

sudo pacman -Syy         # Update the pacman database
sudo pacman -Ss cppcheck # Find and show the latest version of Cppcheck
sudo pacman -S cppcheck

Steps

  1. (Optional) Uninstall Cppcheck if you have an old version in your system
sudo apt remove cppcheck
  1. Install cmake.
sudo apt install cmake # Ubuntu/Debian
  1. Clone the source code from Github.
git clone https://github.com/danmar/cppcheck.git
  1. Follow the compilation guide from Cppcheck. This process may take some time, depending on your hardware.
cd cppcheck
mkdir build
cd build
cmake ..
cmake --build .
  1. The Cppcheck is now ready at bin/cppcheck, you can use it with the following command.
./bin/cppcheck <source-file>
  1. (Optional) You can also copy the cppcheck and it's config file to the right place by this command.
sudo make install
  1. (Optional) Setup the PATH environment variable.
# Setup the PATH
echo "PATH=/usr/local/bin/cppcheck:$PATH" >> ~/.bashrc
source ~/.bashrc
  1. (Optional) If you want to specify the config directory of Cppcheck, you can modify step 3 & 5.
make SRCDIR=build CFGDIR=/usr/share/cppcheck/
sudo make install CFGDIR=/usr/share/cppcheck/

Uninstall

cd build
sudo make uninstall