Compiling on Linux: 3 Steps to Creating Binaries 🔥
Key Summary
- Most software follows a 3-step process to compile from source code:
./configure && make && make install
. - The script configure checks the dependencies, make generates the executable, and tools such as autoconf/automake automate this process.
- Installation is usually optional, making it easier to run commands copied into directories in the
PATH
of system.
Compiling from source code can seem intimidating compared to using package managers, but with three basic commands, the process is simple and straightforward. 🚀
What is Compiling from Source Code?
The programs you use can be interpreted or compiled. Interpreted programs are text files containing code that another program (the interpreter) executes in real time. Compiled programs, on the other hand, are binary files containing machine code ready to be executed.
Compiled executables are very common, especially in large programs. When you compile from source code, yousas a compiler like gcc
to convert the code into an executable program, often distributed across multiple files.

The compilation process can be extensive and complex, which is why it is usually automated with programs such as make
. The files makefiles control how the final executable is built.
In large projects, these makefiles They can be so complex that they are automatically generated with tools such as autoconf and automake to ensure compatibility across different architectures. 🛠️
3-Step Build Process: Configure, Make, Install
Most software uses this basic pattern to compile from source code:
./configure && make && make install
Popular programs like Apache use this sequence (or some variant), such as explains his file INSTALL:

Node.js also follows this structure, as indicated in its BUILDING.md file:

Each project may have slight variations from this command string. Use the logical AND operator (&&
) stops the process if any step fails:
./configure && make && make install
Or you can run each command separately on a single line with a semicolon, although this will run all commands without stopping if any fail:
./configure; make; make install
You can also do the three lines separately:
./configure make make install
If you just want to try the program without installing it, you can skip make install
and run it from its folder.
configure
Ready, while others (like grep) require running another script first to generate it. Always refer to the INSTALL, BUILD, or README file to follow the project's recommendations. 📋How ./configure Starts the Process
The script configure
It is the starting point of the compilation process, adapting the project to your environment.
This script checks the dependencies required for the project, checking versions and availability. Upon completion, it generates a file named Makefile
for the next phase.
The script configure
offers many configurable options with ./configure --help
, allowing you to customize build details.
configure
as make
generate a lot of output on the screen. Use the option --quiet
if you want to run these commands without showing so much detail. 🤫If the script is missing configure
, some projects include a script like autogen.sh
to generate it. For example, htop uses it:

Very simple projects or projects written in other languages may not have configure
. There the process is in two steps: make && make install
.
The script configure
It also controls installation details, such as the parameter --prefix
, which sets the installation root directory. By default it is /usr/local
, but you can change it to better organize your files.
make does most of the work
After configure
generates a Makefile
, the actual compilation of the software begins with make
.
This program reads the Makefile
and follows rules to decide which files to create or update. The Makefiles
handwritten are easy to understand for those who know the syntax.
For example, this one Makefile
simple compiles a program that depends on the file program.c
:
program: program.c gcc -o program program.c
make
check if program.c
changed since the last compilation. If it didn't change, do nothing; if it did, compile with gcc
.

The makefiles
automatically generated are usually much more complex. For example, the makefile
htop has 2,440 lines:

But you don't need to understand every detail. Unless you modify the source code, just run it. make
and let the system take care of it.
The step make
It may take minutes or longer for large projects. If it fails, it's usually due to missing dependencies. The advantage is that make
saves progress and resumes where it left off when you run again.
Finishing with make install
After compiling, the created executable is usually located in the root of the project or in a subdirectory called bin
. You can run it using the full path:

This is useful for testing, but in the long run you'll want to install it in an accessible location.
The objective install
that defines the makefile
Copy the necessary files and set permissions. The default location is /usr/local/bin
, although you can change it with --prefix
.
If you don't have permissions for that folder, run sudo make install
and provides the administrator password.
The installation directory must be included in your variable PATH
to be able to run the program with just its name, without specifying the full path.