# 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`.
```bash
sudo pacman -Syy # Update the pacman database
sudo pacman -Ss cppcheck # Find and show the latest version of Cppcheck
sudo pacman -S cppcheck
```
## Steps
0. (Optional) Uninstall Cppcheck if you have an old version in your system
```bash
sudo apt remove cppcheck
```
1. Install `cmake`.
```bash
sudo apt install cmake # Ubuntu/Debian
```
2. Clone the source code from Github.
```
git clone https://github.com/danmar/cppcheck.git
```
3. 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 .
```
4. The Cppcheck is now ready at `bin/cppcheck`, you can use it with the following command.
```bash
./bin/cppcheck <source-file>
```
5. (Optional) You can also copy the `cppcheck` and it's config file to the right place by this command.
```bash
sudo make install
```
6. (Optional) Setup the `PATH` environment variable.
```bash
# Setup the PATH
echo "PATH=/usr/local/bin/cppcheck:$PATH" >> ~/.bashrc
source ~/.bashrc
```
7. (Optional) If you want to specify the config directory of Cppcheck, you can modify step 3 & 5.
```bash
make SRCDIR=build CFGDIR=/usr/share/cppcheck/
sudo make install CFGDIR=/usr/share/cppcheck/
```
## Uninstall
```bash
cd build
sudo make uninstall
```