How do I install Cppcheck using tar file in Linux?

I am trying to install Cppcheck via telnet on Linux. I have a cppcheck-1.67.tar file and I am unpacking it. I don't see anything that sets this up for me. Am I approaching this correctly?

+3


source to share


5 answers


The current date this answer was posted.

  1. Download the file from there https://sourceforge.net/projects/cppcheck/

  2. Go to the download folder

    cd ~/Downloads/
    
          

  3. Unpack archive

    tar -xvf cppcheck-1.76.1.tar.bz2
    
          

  4. Go to the unpacked folder

    cd cppcheck-1.76.1/
    
          

  5. Install package as root

    sudo make install
    
          

  6. Check the result

    $ which cppcheck
    /usr/bin/cppcheck
    
          

  7. 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

      

+3


source


Instructions are in readme.txt

. The short answer is make install

.



Remember to never install things from a tar file when you can use your distribution package manager.

+1


source


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.

+1


source


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

      

+1


source


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

      

0


source







All Articles