How do I install Cppcheck using tar file in Linux?
The current date this answer was posted.
-
Download the file from there https://sourceforge.net/projects/cppcheck/
-
Go to the download folder
cd ~/Downloads/
-
Unpack archive
tar -xvf cppcheck-1.76.1.tar.bz2
-
Go to the unpacked folder
cd cppcheck-1.76.1/
-
Install package as root
sudo make install
-
Check the result
$ which cppcheck /usr/bin/cppcheck
-
Testing this
$ touch simple.c $ echo "int main(){ int a; a + 1; return 0}" > simple.c $ cppcheck simple.c Checking simple.c ... [simple.c:1]: (error) Uninitialized variable: a
This package also exists in the standard repository.
$ aptitude search cppcheck
p cppcheck - tool for static C/C++ code analysis
Test environment
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux
source to share
The readme.txt file does not mention "make install".
It looks like the supplied Makefile is running:
-
It passes the "CFG =" parameter to compile without DESTDIR
-
But "make install" adds DESTDIR to CFGDIR
In my case, I edited the Makefile to remove DESTDIR from make install and cppcheck is happy with that.
source to share
For me, the magic lines turned out to be the following in Docker on Ubuntu 18.04 (Bionic Beaver):
RUN cd /tmp \
&& git clone https://github.com/danmar/cppcheck.git \
&& cd cppcheck \
&& git checkout 1.72 \
&& make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes install \
&& cd /tmp \
&& rm -rf /tmp/cppcheck \
&& ldconfig
I assume the following will work for any version. I'm not sure where it makes sense to set the config. This works for me:
make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes install
source to share
If you don't have sudo
privileges you can follow @ Seti Volkylany's answer , step 5 replacing
OUT_PATH=/home/user/bin # target location of binary
make SRCDIR=build CFGDIR=~/Downloads/cppcheck-1.76.1/cfg PREFIX=$OUT_PATH
make install CFGDIR=$OUT_PATH/cppcheck-1.76.1/cfg PREFIX=$OUT_PATH
source to share