Building software from source on an RPM-based Linux distribution—Fedora, RHEL, Rocky Linux, AlmaLinux, openSUSE—means compiling code into a binary and then deciding how to install it. The direct answer: install the development toolchain and the library packages the program needs (the "build dependencies"), unpack the source into a scratch directory, run the project's configure step, compile, and install either into /usr/local under your own control or as a proper RPM package you can track, upgrade, and remove. The second path is what separates a clean system from one littered with untracked files, and it's the method worth learning even though it takes a little more setup. Everything below assumes a normal user account with sudo rights and a network connection for package installation.
First, Know Which Path You're On
There are three common outcomes when you "build from source" on an RPM system, and the right procedure depends on which one you want.
The first is a local build for yourself: you compile and install into /usr/local (the default prefix for most autotools projects) or into a directory in your home folder. This is fast, needs no packaging knowledge, and is fine for testing a new version of a tool. The downside is that the package manager has no record of it, so upgrades and removals are manual.
The second is an RPM package built from upstream source, typically using the rpmbuild tool and a spec file. You get a .rpm you can install, query, and erase with the same commands as any distribution package. This is the right choice when you need a specific upstream version the distro doesn't ship, when you want to deploy the same build to several machines, or when you plan to keep the software around.
The third is a rebuild of a distribution source package, where you take the distro's own .src.rpm, adjust it, and rebuild. That's a variant of the second path and mostly matters if you're patching an existing package rather than packaging something new.
The rest of this article covers the toolchain and dependency work that all three share, then walks through the local build, then the RPM packaging route in enough detail to produce a working package for a simple project.
Prerequisites: Toolchain, Headers, and a Clean Workspace
Before touching any source tarball, confirm you have the basics. On Fedora and its relatives, the development toolchain group pulls in the compiler, make, and related tools:
rpm-build provides rpmbuild; rpmdevtools provides the rpmdev-setuptree helper that creates the standard build directory layout. On older RHEL-family systems the package manager is yum, and the group name may differ slightly—check with dnf grouplist or yum grouplist rather than guessing.
Building also needs the development headers for every library the program links against. A runtime library package like openssl-libs is not enough; you need openssl-devel. This is the single most common source of failed builds, and the error messages usually name the missing header file (for example, fatal error: openssl/ssl.h: No such file or directory), which you can translate into a package name with dnf provides:
That command tells you which package owns the file, and installing the -devel package it names usually resolves the error.
Do the work in a scratch directory, never inside /usr or a system path:
Keep your source tarballs and extracted trees here. It keeps the system clean and makes it obvious what to delete when you're done.
Reading the Project's Build Instructions First
Every source tree ships instructions, and they differ enough that skipping them wastes time. Look for README, INSTALL, BUILDING, or a docs/ folder. Most projects fall into one of a few build systems:
Autotools (configure script, then make, then make install). The most common for older and many current C projects. CMake (cmake to configure, then make or ninja). Increasingly common; uses an out-of-tree build directory. Meson (meson setup build, then ninja -C build). Common in newer projects. Language-specific builds: cargo build --release for Rust, go build for Go, pip/poetry for Python, npm for Node. These often need no system toolchain at all, but may still link against system libraries.
The instructions tell you which dependencies to install and which options to pass. Follow them; don't improvise flags a project doesn't document.
The Local Build: Configure, Compile, Install, Check
This is the fastest route and the one to use for a quick test. Using an autotools project as the example:
1: Fetch and verify the source. Download the release tarball and, if the project publishes checksums, verify it: sha256sum file.tar.gz and compare against the published value. Unpack: tar xf file.tar.gz && cd file-version.
2: Configure. Run ./configure --prefix=/usr/local. The prefix decides where files land; /usr/local is the conventional place for locally built software and is already on the default PATH. Add project-specific flags from the instructions (for example, --disable-docs to skip documentation builds you don't need). Read the summary the script prints at the end—it lists what was found and what was missing.
3: Compile. Run make -j$(nproc). The -j flag builds in parallel using all available cores, which cuts build time substantially on multi-core machines. If it fails, the error is almost always a missing dependency or a compiler version mismatch; the last 20 lines of output usually name the file and the missing symbol.
4: Test (optional but useful). Many projects support make check or make test. Running it confirms the build actually works before you install anything.
5: Install. Run sudo make install. Files go under /usr/local/bin, /usr/local/lib, and so on.
6: Check success. Run which program to confirm the binary is found, then program --version to confirm it runs. If the binary reports a missing shared library at runtime, the library it needs isn't in the linker's search path; ldd $(which program) lists what it links against and flags anything "not found."
To remove a locally built autotools install later, run sudo make uninstall from the same source tree if the project supports it. If it doesn't, you're left removing files by hand—which is exactly the argument for the RPM path.
Building an RPM: The Directory Layout and Spec File
This is the part worth doing properly. The RPM build system expects a fixed directory structure under your home directory, and rpmdev-setuptree creates it:
That produces ~/rpmbuild/ with SOURCES, SPECS, BUILD, RPMS, and SRPMS subdirectories. Your source tarball goes in SOURCES; your spec file goes in SPECS; finished packages appear in RPMS.
A spec file is the recipe. It has a header section (metadata), a %prep section (unpack the source), %build (compile), %install (copy files into a staging root), %files (list what the package owns), and scriptlets if needed. Here's a minimal working example for a hypothetical simple program, hello, version 1.0:
A few things to note. %{?dist} appends the distribution tag (like .fc42) automatically. %autosetup unpacks and applies patches. %configure and %make_build are macros that expand to the standard flags the distro uses, including correct compiler flags and install paths—using them instead of raw commands keeps your build consistent with distro conventions. %make_install runs the install step into the build root rather than the live system. The %files section must list every file the package installs, or the build fails at the file-checking stage. %doc marks documentation files for installation under the doc directory.
Put the spec in ~/rpmbuild/SPECS/hello.spec, the tarball in ~/rpmbuild/SOURCES/, and build:
The -ba flag builds both the binary and source packages. Output lands in ~/rpmbuild/RPMS/ and ~/rpmbuild/SRPMS/. Install the result with sudo dnf install ./hello-1.0-1.fc42.x86_64.rpm—the ./ prefix tells dnf to use the file rather than a repository.
Diagnosing Build Failures: Symptoms and Likely Causes
Builds fail in a limited number of ways, and the error text usually names the cause. Start with reversible checks before changing anything permanent.
Missing header at compile time. Symptom: fatal error: something.h: No such file or directory. Cause: the -devel package for that library isn't installed. Check with dnf provides '*/something.h' and install what it lists.
Configure can't find a library. Symptom: the configure summary says a library was "not found" even though it's installed. Cause: the library's runtime package is present but not the development package, or the library is in a nonstandard path. Install the -devel package; if it's genuinely elsewhere, pass --with-something=/path as the project documents.
Undefined reference at link time. Symptom: undefined reference to 'function'. Cause: a library isn't being linked, often because the link flags don't include it. This one frequently indicates a missing dependency the spec file doesn't declare. Add the right BuildRequires and try again.
Version mismatch with the compiler. Symptom: errors about C or C++ standard revisions, or warnings treated as errors. Cause: the source expects a newer or older compiler than you have. Check the project's minimum requirements; if your distro's compiler is too old, that's a stop condition for a straightforward build and may require a newer distribution or a different source version.
RPM's "installed (but unpackaged) file(s) found." Symptom: the build succeeds but packaging fails at the file check. Cause: %files doesn't list everything in the build root. Add the missing paths.
RPM's "File listed twice" or "Bad exit status." Cause: overlapping entries in %files or a failed command in a scriptlet. Trim the duplication; check the exit code of each command.
If a build keeps failing in ways that point at a broken or patched-up system, or if you're modifying distro packages in a way that affects system libraries, stop and work with a maintainer or in an isolated container rather than pushing changes into a production system. That's the sensible boundary: routine dependency fixes are something you can do; rebuilding core system libraries on a machine you depend on is not a casual operation.
When to Prefer the Distribution Package Instead
It's worth being honest about the trade-off. A distribution package (dnf install hello) comes with security updates, dependency resolution, and a removal path. A source build you maintain yourself comes with none of that unless you take on the work.
The source route makes sense when you need a version newer than the distro ships, when the software isn't packaged at all, when you need a build-time option the distro's package doesn't enable, or when you're developing against the software. The RPM-building route makes sense over a raw local build whenever the software will stay on the machine, because it gives you dnf remove, version tracking, and a clean %files inventory.
What source building doesn't give you is automatic security patching. If you build a web-facing service from source and never update it, you've created a maintenance burden that the distro would otherwise have handled. Plan for that: track upstream releases, set a reminder to rebuild, or keep the software confined to a role where staleness is acceptable.
A Worked Estimate of the Effort
For a simple C program with two or three dependencies, expect the whole RPM route to take under an hour the first time—most of it spent learning the spec syntax, not fighting the compiler. Subsequent packages are much faster because the layout, the macros, and the dependency-checking habits carry over. The local /usr/local route takes a few minutes once dependencies are installed but leaves cleanup to you. The biggest time sink in both cases is dependency resolution, which is why dnf provides and the project's own documentation are the two tools you'll reach for most.
One more check worth adopting: after building an RPM, install it on a clean test system or container before trusting it in production. A package that installs and runs on the machine that built it can still fail elsewhere if a runtime dependency is missing; testing on a fresh system catches that. And keep your spec files and tarballs under version control or in a backup, because a dropped SPECS directory means rebuilding the recipe from memory.