How do I install Cppcheck using the tar file on Linux? - linux

I'm trying to install Cppcheck via telnet on a Linux box. I have the cppcheck-1.67.tar file and I untar it. I don't see anything that will install it for me. Am I approaching this the correct way?

Actual on a date publication of this answer.
Download file from there https://sourceforge.net/projects/cppcheck/
Go to the folder with for downloads
cd ~/Downloads/
Unpack archive
tar -xvf cppcheck-1.76.1.tar.bz2
Go to unpacked folder
cd cppcheck-1.76.1/
Install package as root
sudo make install
Check up result
$ which cppcheck
/usr/bin/cppcheck
Testing it
$ 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 a standard repository.
$ aptitude search cppcheck
p cppcheck - tool for static C/C++ code analysis
Testing 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

The instructions are in the readme.txt file. The short answer is make install.
Remember never to install things from a tar file when you can use your distribution's package manager.

The readme.txt file makes no mention of "make install".
It looks like the supplied Makefile is borked:
It passes "CFG=" param to compile, without DESTDIR
But "make install" prepends DESTDIR to CFGDIR
In my case, I edited Makefile to remove DESTDIR from make install, and cppcheck is happy with that.

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 am not sure where it makes sense to install the configuration to. This works for me:
make SRCDIR=build CFGDIR=/usr/bin/cfg HAVE_RULES=yes install

If you want a later version than in the other answers, and you want to install it, then you can use the bash script below which is up to date and builds on the other answers. It should also clean itself up afterwards. It works for version 2.7 on debian/ubuntu but you can change the git checkout tag and try your luck on newer versions.
installcppcheck.sh
#!/usr/bin/env bash
set -e
cd /tmp
git clone https://github.com/danmar/cppcheck.git
cd cppcheck
git checkout 2.7
make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" install
cd /tmp
rm -rf /tmp/cppcheck
ldconfig
cppcheck --version

If you don't have sudo privileges you can follow #Seti Volkylany's answer, replacing step 5 with
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

Related

How to manually install and uninstall Rust?

I'd like to try on a "hello world" program on Rust. I didn't choose rustup for auto-installation but downloaded the standalone installer. I thought I could follow the classic way to manually install it on Linux platform bundled with GCC and Clang below,
$ tar xf rust-xxx.tar.gz; mv rust-xxx $RUST_HOME
$ cd /usr/local/bin; sudo ln -s $RUST_HOME/bin/rustc
$ rustc hello.rs; ./hello
However I found install.sh inside, so I have to run it for the installation, don't I? How to completely uninstall it afterwards?
I just downloaded the archive you linked and had a look inside the installation script.
During installation it will create an uninstall.sh script and actually print out for you the location:
install_uninstaller() {
local _src_dir="$1"
local _src_basename="$2"
local _abs_libdir="$3"
local _uninstaller="$_abs_libdir/$TEMPLATE_REL_MANIFEST_DIR/uninstall.sh"
msg "creating uninstall script at $_uninstaller"
run cp "$_src_dir/$_src_basename" "$_uninstaller"
critical_need_ok "unable to install uninstaller"
}
#...
# Install the uninstaller
install_uninstaller "$src_dir" "$src_basename" "$abs_libdir"

How to make a ubuntu executable and run it in my install file

This is the install file below (sandhi-install.sh). Currently after installing it can only be run from the terminal. I want to make it terminal independent. Making a Ubuntu executable explains how to create an executable but where should I put that code. I think it should be in the install file itself because we want the icon to appear on the desktop after installation completes.
I have no prior experience in Shell scripting and bash so sorry if i miss any important information. Please ask if you need any other file. My aim is basically to run sandhi independent of the terminal.
#!/bin/bash
echo "Installing the required dependencies"
sudo apt-get -y install git-core autoconf automake make libtool g++ python-dev swig \
pkg-config libboost1.48-all-dev libfftw3-dev libcppunit-dev libgsl0-dev \
libusb-dev sdcc libsdl1.2-dev python-wxgtk2.8 python-numpy \
python-cheetah python-lxml doxygen python-qt4 python-qwt5-qt4 libxi-dev \
libqt4-opengl-dev libqwt5-qt4-dev libfontconfig1-dev libxrender-dev \
python-serial python-matplotlib
echo "Sciscipy installation starting"
git clone https://github.com/manojgudi/sciscipy-1.0.0.git
cd sciscipy-1.0.0/
sudo ./install
echo "Starting Sandhi installation"
cd ../
git clone http://github.com/manojgudi/sandhi.git
cd sandhi/
git submodule init
git submodule update
git pull origin master
git submodule update
mkdir build
cd build/
cmake ../
make -j 2
sudo make install
sudo ldconfig
echo "Sandhi installation complete. Go to command line and type Sandhi to start Sandhi"
Your script already has all the right ingredients for being a *nix executable - a shebang line and what at least looks like valid code for the interpreter (/bin/bash). All you need to do is to give the relevant user and/or group (or everybody) execute access on the file. For example, if you're the owner of the file:
sandhi#host$ ls -l sandhi.sh
-rw-r--r-- 1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi#host$ chmod u+x sandhi.sh
Now you can execute it:
sandhi#host$ ls -l sandhi.sh
-rwxr--r-- 1 purak users 3.5K Oct 11 16:55 sandhi.sh
sandhi#host$ ./sandhi.sh
For the rest of the question it's unclear what you're asking. The accepted answer to Making a Ubuntu executable says that if the executable foo.bin is in /usr/local/bin (a sensible destination for custom executables) the line in the desktop entry should be Exec=/usr/local/bin/foo.bin.

How to install libraries on jhbuild?

I want to start to use jhbuild. It creates an isolated system to compile unstable packages ant try them. But it's not clear to me how to add a missing library to it.
Steps:
$ sudo apt-get install jhbuild
$ mkdir -p /opt/gnome
$ chown `whoami`.`whoami` /opt/gnome
$ mkdir ~/checkout/gnome
$ jhbuild bootstrap
... all correct ...
$ jhbuild sysdeps --install
... problems ...
Required packages:
Packages too old:
(none)
No match with system package
soundtouch (soundtouch-1.4.pc, required=0)
libicu (icu-i18n.pc, required=4)
libunistring
yajl
device-mapper
...
I read something about installing libicu here, but It do not explain where to checkout an how to compile.
I have tried
$ svn checkout http://source.icu-project.org/repos/icu/icu/tags/release-4-8/
$ cd release-4-8/source
$ ./autogen.sh --prefix=/opt/gnome
$ make
$ make install
with no luck.
My system is a 64bits one. I say because I have made this hack already
If you have a 64bit system and jhbuild is installing into /opt/gnome then you need to set your libdir to install libraries into /opt/gnome/lib64
add --libdir=/opt/gnome/lib64 onto the autogen.sh line.
You can just run sudo-apt get install libicu. The sysdeps are system dependencies, so they don't need to be installed in the JHBuild checkout, just on your system.
You might find this wiki page helpful: https://wiki.gnome.org/HowDoI/Jhbuild

Failed to compile module vmmon vmware

I'm going to install VMware 8 on debian 6 with 3.2.xx kernel. I've installed it thoroughly and it seemed that there wasn't any error in installing process.but when I want to run VMware workstation it got an error which says:
Failed to compile module vmmon
what is the cause of this error and how can I solve it?
log ouput:
2012-10-11T19:29:37.521+03:30| vthread-3| I120: Building module with command: /usr/bin/make -j -C /tmp/vmware-root/modules/vmmon-only$
2012-10-11T19:29:39.324+03:30| vthread-3| I120: Failed to compile module vmmon!
I user this commands to solve my problem:
# cd /usr/lib/vmware/modules;
# wget http://pavlinux.ru/vmware/8.0.0/source.tar.lzma;
# tar -xf source.tar.lzma;
# vmware-modconfig --console --install-all;
You need to run this command as root after each kernel upgrades :
vmware-modconfig --console --install-all
Solved in this way
Check your version $ vmplayer -v to insert in the script, in my case is 14.1.7
$ vim vmware-repair.sh
press i and paste
#!/bin/bash
VMWARE_VERSION=workstation-14.1.7 #This needs to be the actual name of the appropriate branch in mkubecek's GitHub repo for your purposes
TMP_FOLDER=/tmp/patch-vmware
rm -fdr $TMP_FOLDER
mkdir -p $TMP_FOLDER
cd $TMP_FOLDER
git clone https://github.com/mkubecek/vmware-host-modules.git #Use `git branch -a` to find all available branches and find the one that's appropriate for you
cd $TMP_FOLDER/vmware-host-modules
git checkout $VMWARE_VERSION
git fetch
make
sudo make install
sudo rm /usr/lib/vmware/lib/libz.so.1/libz.so.1
sudo ln -s /lib/x86_64-linux-gnu/libz.so.1 /usr/lib/vmware/lib/libz.so.1/libz.so.1
systemctl restart vmware && vmplayer &
Press ESC then :wq then ENTER
$ chmod +x vmware-repair.sh
$ sudo ./vmware-repair.sh
Source
This could help future users with the same problem
git clone https://github.com/mkubecek/vmware-host-modules
cd vmware-host-modules
git checkout workstation-16.2.3
sudo make ; sudo make install

Installing Git with non-root user account

I've already set up a Git repository on GitHub and committed a few changes from my Windows machine.
But tomorrow I'll have to work in this repository from a machine running Ubuntu with limited privilege (i.e. no sudo).
Is there a portable version of Git for Linux? Or some source that allows me to compile and install Git only for the current user?
You can download the git source and do ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well.
I don't like link-only answers, but this link I followed step-by-step on a Fedora machine and it worked without modification. Very, very easy. The binaries end up in your ~/bin directory. You download a tarball, extract the sources, run make and run make install and that is it.
As the author states, the 2 prerequisites are gcc and ssh and if you meet these git should work for you as a non-root user.
To install git and dependencies from source the following maybe useful.
Replace with the location you are installing your non-root apps and consider checking for latest versions of source code.
wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
tar -xf curl-7.47.1.tar.gz
mkdir <local_curl_dir>
cd curl-7.47.1
./configure --prefix=<local_curl_dir>
make
make install
wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar -xf expat-2.1.0.tar.gz
mkdir <local_expat_dir>
cd expat-2.1.0
./configure --prefix=<local_expat_dir>
make
make install
wget https://github.com/git/git/archive/v2.6.4.tar.gz
tar -xf v2.6.4
mkdir <local_git_dir>
cd git-2.6.4
make configure
./configure --prefix=<local_git_dir>/git --with-curl=<local_curl_dir>/curl --with-expat=<local_expat_dir>/expat
make
make install
This is what I ended up doing, the main trick being the make flags:
wget -O git.tar.gz https://github.com/git/git/archive/v2.17.0.tar.gz
tar zxf git.tar.gz
mv git-2.17.0 git
cd git
make configure
./configure --prefix=`pwd` --with-curl --with-expat
# ./configure --prefix=`pwd`
# Make flags from https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
make NO_GETTEXT=Nope NO_TCLTK=Nope
make install NO_GETTEXT=Nope NO_TCLTK=Nope
Credits:
79E09796's answer above was a good tip, but didn't work for my case on Cloudways and did not require compiling curl and expat.
A random email record I found on the internet: https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA#mail.gmail.com/
A related answer is https://askubuntu.com/a/350.
I could get it work with the third method proposed:
apt-get source git
cd git_vXXX
./configure --prefix=$HOME
make
make install
I don't know why, but when I had tried to install from the source download from github instead, I had a lot of problems with missing dependencies
Overkill workaround
Install Anaconda as a user and install git with conda.
Advantages
Anaconda can be installed as user, and a conda environment can be created which can help you to install other packages. This way you don't need to compile git from source, nor you need to install libcurl and perl, so you won't get the error
git: 'remote-https' is not a git command. See 'git --help'
after successfully compiling git.
Steps to install Anaconda, then git
read the Anaconda installation manual which points to the download page's shell script file.
Download the script file:
copy to your local machine and then copy with scp (e.g. winscp) to the Linux machine or
use a terminal on the Linux machine and issue wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh.
add executable rights to yourself on the file by issuing chmod +x Anaconda3-2020.11-Linux-x86_64.sh
follow the installation instructions where you can also specify into which folder you want to install anaconda
after installation, chose one of the possibilities below to successfully invoke git later:
you either activate a conda environment, which is useful e.g. if you need to create different conda environments (it is common if you work with python). To activate an environment, you need to ask the installer (at the end of the installation) to add the conda initialization code into your ~/.bashrc file [see below]. Using this method, your path won't be polluted, and you will see if conda-related binaries are also in your current path. Or you can
add the installed bin's folder to your path, e.g. if you installed anaconda into /home/myusername/anaconda3, it will be in /home/myusername/anaconda3/bin. Your new executable file conda will be also there which will help you to install packages like git, python or pandoc, or
cd into the binary folder of anaconda, e.g. cd /home/myusername/anaconda3/bin, and execute the commands below.
don't forget to take into effect the new settings by, e.g., closing and opening the terminal again if you selected method 1. or 2. in point 5. If you selected 1, you will see something like (base) myusername#servername indicating you are using the base conda environment.
Now you can install git using conda by issuing conda install -c anaconda git.
Your .bashrc will contain likes like this if you told the Anaconda installer to initialize conda for you:
# content of your .bashrc in your home dir
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myusername/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/myusername/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/myusername/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/myusername/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
for the latest version(which i mean git-2.25.0-rc1 or upper), you need to
wget https://github.com/git/git/releases/tag/v2.25.0-rc1 -O git.zip
unzip git.zip
cd git-2.25.0-rc1
export PATH=`pwd`:$PATH
and of course, you can add the last line into your .bashrc or .zshrc or something else for more convenience.

Resources