Post

Building Software from Source on Linux: configure, make, and checkinstall

Building Software from Source on Linux: configure, make, and checkinstall

Most of the time the distro’s package manager has what you need. Building from source is for the rest of the time: a newer version than your repo carries, a custom compile-time flag, or software that simply isn’t packaged for your distro. This post covers the classic build flow and, critically, how to do it without leaving your package manager blind to what you installed.

When You Actually Need This

Before reaching for ./configure, check whether there’s a legitimate reason to skip the package manager.

1
2
3
4
5
6
# Is it already packaged, maybe under a slightly different name?
apt search nginx 2>/dev/null | head
dnf search nginx 2>/dev/null | head

# Is there a vendor repo or backport with a newer version?
# (nginx.org, PPAs, EPEL, etc. — check before compiling)

Tip: “I need the latest version” is often solved by adding the vendor’s own apt/yum repo rather than compiling by hand. Save source builds for things with no packaged option or that need custom ./configure flags.

Installing a Build Toolchain

Every distro bundles its C/C++ toolchain, headers, and build utilities into one metapackage.

1
2
3
4
5
6
7
8
9
# Debian/Ubuntu
sudo apt install build-essential

# RHEL/CentOS/Fedora
sudo dnf groupinstall "Development Tools"

# Confirm the essentials are there
gcc --version
make --version

Tip: build-essential/Development Tools gets you gcc, make, and friends, but a given project’s ./configure will often demand additional -dev/-devel packages (like libssl-dev) that aren’t part of this base set.

Fetching and Extracting the Source

Source releases are almost always a compressed tarball with a version number baked into the directory name.

1
2
3
4
5
6
wget https://example.org/releases/widget-2.4.1.tar.gz
tar xzf widget-2.4.1.tar.gz
cd widget-2.4.1

# Read these before doing anything else
cat README INSTALL 2>/dev/null | less

Tip: INSTALL or README sometimes documents project-specific ./configure flags or required dependencies that generic instructions like this one can’t anticipate. Five minutes of reading saves a failed build later.

Running configure

./configure is a shell script, generated by Autoconf, that probes your system for compilers, libraries, and headers, then writes a Makefile tailored to what it found.

1
2
3
4
5
6
./configure --prefix=/usr/local --enable-ssl
# checking for gcc... gcc
# checking for a BSD-compatible install... /usr/bin/install -c
# checking for stdint.h... yes
# ...
# config.status: creating Makefile

Tip: --prefix controls where make install will later place files. /usr/local is the conventional target for hand-built software, keeping it clearly separate from files your package manager owns under /usr.

Handling Missing-Dependency Errors

A configure failure almost always names exactly what’s missing; the error just doesn’t tell you the package name for your distro.

1
2
3
4
5
6
7
8
9
10
./configure
# checking for OpenSSL... configure: error: OpenSSL development files not found

# Debian/Ubuntu: the dev package, not just the runtime library
sudo apt install libssl-dev
# RHEL/Fedora
sudo dnf install openssl-devel

# Then re-run configure
./configure --enable-ssl

Tip: The runtime library (libssl3) and its development package (libssl-dev) are separate packages on purpose. configure needs the headers and .so symlinks that only the -dev/-devel package provides.

Compiling

With a Makefile in place, make compiles each source file and links the result, using the rules configure generated.

1
2
3
4
5
# Use all available CPU cores to compile in parallel
make -j"$(nproc)"

# Watch for warnings vs hard errors; warnings are usually safe to ignore
# for a one-off build, errors are not

Tip: -j$(nproc) turns a ten-minute single-threaded build into a couple of minutes on a modern multi-core machine. There’s rarely a reason to leave it off for a local build.

Why Bare make install Is a Trap

make install copies files straight onto your filesystem with no record anywhere that your package manager can see.

1
2
3
4
5
6
sudo make install
# Installs to /usr/local/bin, /usr/local/lib, /usr/local/share, etc.
# but dpkg/rpm now know nothing about these files

dpkg -S /usr/local/bin/widget
# dpkg-query: no path found matching pattern /usr/local/bin/widget

Tip: Six months later, “where did this binary come from and how do I cleanly remove it” becomes a real problem if you’ve forgotten. That’s exactly the gap the next step closes.

Packaging the Build with checkinstall

checkinstall watches what make install does and wraps the result in a real .deb or .rpm, so your package manager can track and later remove it cleanly.

1
2
3
4
5
6
7
8
9
10
sudo apt install checkinstall   # or: sudo dnf install checkinstall

# Instead of 'make install', run:
sudo checkinstall
# Prompts for package name, version, description, then builds
# widget_2.4.1-1_amd64.deb and installs it via dpkg

# Now it's a real, trackable package
dpkg -l | grep widget
dpkg -L widget

Tip: checkinstall isn’t perfect — it can miss files a build touches outside the directories it monitors — but it’s a large improvement over an untracked make install, and cleanly uninstallable with dpkg -r or rpm -e when you’re done.

Cleaning Up and Rebuilding

Configuration and object files from one build can poison a later one, especially after changing ./configure flags.

1
2
3
4
5
6
7
8
9
# Remove compiled objects and binaries, keep configure's output
make clean

# Remove everything configure generated too, back to a pristine source tree
make distclean

# Then start over
./configure --prefix=/usr/local --enable-ssl
make -j"$(nproc)"

Tip: If a build fails in a confusing way after you’ve already tried changing flags once, make distclean before retrying is often faster than debugging stale cached configure output.

This post is licensed under CC BY 4.0 by the author.