Installing from source code is one useful feature for Linux users. You can install any app not present in the App Store for the distribution you are using. However, the real complication starts when you no longer needs it and wants to uninstall / remove it.

The primary reason why you may need installing from source code is its unavailability in the App Store. You may stumble upon a gitlab/github project which is in development phase and presents no other mode installation. The other reason could be the App Store not offering the version you want to use – since it mostly provides the latest release of an Application.

CheckInstall makes the installation (and uninstall) of an application from its source code easier by keeping a track of all the files created or modified. It does so by creating a binary package which could be a Debian, RPM or Slackware package. This package can be installed using any package manager and you can uninstall it later without the hassle of removing all associated files / directories / dependencies manually.

Install checkinstall

To install checkinstall, open terminal and use below command

sudo apt-get install checkinstall

checkinstall –help shows you how to use it.

Usage: checkinstall [options] [command [command arguments]]
Options:

Package type selection

-t,–type= Choose packaging system
-S Build a Slackware package
-R Build a RPM package
-D Build a Debian package

Now, lets try to install an application using checkinstall. For simplicity, I am using a small Terminal Emulator st.

checkinstall – installing from source code

You can download the stable st terminal emulator from the link below

https://dl.suckless.org/st/st-0.8.2.tar.gz

Once downloaded, fire up a terminal and navigate to ‘st’ directory. To compile and install, you may have to install the dependencies first which are needed in compilation.

sudo apt-get install libx11-dev libxft-dev
cd st
make

make shows the compilation successful. In case it fails for some missing libraries, read the logs and install the libraries first.

ambarish@thelinuxuser:~/Downloads/ST/st-0.8.2$ make
st build options:
CFLAGS = -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -DVERSION="0.8.2" -D_XOPEN_SOURCE=600 -O
LDFLAGS = -L/usr/X11R6/lib -lm -lrt -lX11 -lutil -lXft -lfontconfig -lfreetype -lfreetype
CC = c99
c99 -I/usr/X11R6/include pkg-config --cflags fontconfig pkg-config --cflags freetype2 -DVERSION=\"0.8.2\" -D_XOPEN_SOURCE=600 -O -c x.c
c99 -o st st.o x.o -L/usr/X11R6/lib -lm -lrt -lX11 -lutil -lXft pkg-config --libs fontconfig pkg-config --libs freetype2

Instead of make install, we will use checkinstall to create a deb package and install it. Make sure you use it with the root permission.

ambarish@thelinuxuser:~/Downloads/ST/st-0.8.2$ sudo checkinstall
 checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
            This software is released under the GNU GPL.
 
 **** Debian package creation selected ***
 
 This package will be built according to these values: 
 0 -  Maintainer: [ root@thelinuxuser ]
 1 -  Summary: [ st terminal emulator ]
 2 -  Name:    [ st ]
 3 -  Version: [ 0.8.2 ]
 4 -  Release: [ 1 ]
 5 -  License: [ GPL ]
 6 -  Group:   [ checkinstall ]
 7 -  Architecture: [ amd64 ]
 8 -  Source location: [ st-0.8.2 ]
 9 -  Alternate source location: [  ]
 10 - Requires: [  ]
 11 - Provides: [ st ]
 12 - Conflicts: [  ]
 13 - Replaces: [  ]
 Enter a number to change any of them or press ENTER to continue: 
 Installing with make install…
 ========================= Installation results ===========================
 mkdir -p /usr/local/bin
 cp -f st /usr/local/bin
 chmod 755 /usr/local/bin/st
 mkdir -p /usr/local/share/man/man1
 sed "s/VERSION/0.8.2/g" < st.1 > /usr/local/share/man/man1/st.1
 chmod 644 /usr/local/share/man/man1/st.1
 tic -sx st.info
 4 entries written to /etc/terminfo
 Please see the README file regarding the terminfo entry of st.
 ======================== Installation successful ==========================
 Copying documentation directory…
 ./
 ./FAQ
 ./TODO
 ./LICENSE
 ./README
 Copying files to the temporary directory…OK
 Stripping ELF binaries and libraries…OK
 Compressing man pages…OK
 Building file list…OK
 Building Debian package…OK
 Installing Debian package…OK
 Erasing temporary files…OK
 Writing backup package…OK
 OK
 Deleting temp dir…OK
 
 Done. The new package has been installed and saved to
 /home/ambarish/Downloads/ST/st-0.8.2/st_0.8.2-1_amd64.deb
 You can remove it from your system anytime using: 
   dpkg -r st
 

Congratulations! You have successfully installed from source code using checkinstall. You can see a .deb package available in the working directory created during the process.

-rw-r--r-- 1 root     root     37080 Dec  8 18:52 st_0.8.2-1_amd64.deb

You can even just build a .deb package without uninstalling by appending –install=no while using checkinstall and later use the deb package to install it. You can use this package to install on other machines with no internet access.

checkinstall --install=no

To uninstall the package, you can use the below command and it will remove all the associated contents.

dpkg -r st

Wrapping up

Though every Linux distribution provides a collection of applications that are more than we need, we may need to install applications from source code sometimes. checkinstall makes the work easier by keeping a tab of the files installed / modified and making it easier to uninstall it later using any package manager or dpkg.

Check some lightweight Linux distributions here.

It’s been there from forever. Do you use it or would still prefer make install? Let us know in the comments.