Use These Four Simple Steps to Compile Linux Programs from Source

Use These Four Simple Steps to Compile Linux Programs from Source

Linux users generally have an easy time finding and installing software. Just about every distribution has a software repository with a nice, graphical front-end. To install a program you usually only have to search for it and then press the “Install” button. If the software isn’t available in the repository, you can usually find pre-compiled binaries online somewhere. Then, it’s a just a matter of running apt-get, yum, or similar (depending on which Linux distribution you are using) to install them. Sometimes, though, you have no option but to compile Linux programs from source yourself, especially if you want the bleeding-edge development version of a program for which no pre-compiled binaries exist.

Want to learn how to compile Linux programs from source? Then read on!

For some reason, the prospect of having to compile Linux programs from source scares many Linux users – even those who have been using the operating system for years. But it need not scare them. Installing software from source code files is a simple operation in most cases. And if you learn the basic techniques, then you’ll soon be able to diagnose the problems that occur on those occasions when things don’t proceed as planned.

Steps Required to Compile Linux Programs from Source

To compile Linux programs from source, use a four-step process:

  1. Unpack the source code
  2. Resolve dependencies
  3. Compile it
  4. Install it

1. Unpacking the Source Code

In this example we’re going to compile the SQLite database. If you want to follow along, download the latest source code tarball (a .tar.gz file).


A tarball is just a compressed file, very similar to a .zip file. It will either have the extension tar.gz or .tgz. To work with its contents you must first extract them using the following command:

Sometimes you will have a (or tar.bz2) file. Use the following command if you’re working with a file:

This process creates a directory with the same name as the file.


2. Resolving Dependencies

Enter this new directory using cd directory name and then, as sudo (or su in many other Linux distributions), execute the ./configure command:


The ./configure command checks to see if all the software that this particular program relies upon – such as an appropriate compiler – is installed. The ./ prefix tells Linux to look for the configure file in the current directory and execute it. Note that sometimes configure is not the name of the file that resolves these dependencies. If you get an error when running configure look in the directory for a “README” or “INSTALL” file or similar. That should tell you which file is responsible for this step. In fact it’s a good idea to read any included files before attempting to compile any program.

If everything goes well, you won’t see any errors. We were lucky here. Usually, though, you will be missing something. Just examine the output and install any missing dependencies using your package manager. Run ./configure again until you don’t see any more errors.

3. Compilation

Once you have resolved all the dependencies, you must compile the program. Use the make command to do this:


This process can take a few minutes and substantially longer for some programs. Make sure that the output does not display any errors before continuing.

4. Installation

At this point you have compiled the binaries, but now you need to install them. Just execute make install. This step moves all the binaries into their correct location on your system so that your program is ready to use:


If you have been following along, execute sqlite3 at a terminal prompt, and if the database has been installed correctly, you should see the sqlite3 database prompt.


Congratulations! But what if you want to remove the program you just installed? That’s simple. Just visit the directory you installed the program from and execute:

Followed by:


It’s easy to install most programs from source in this way, but some require slightly different steps from those shown here. For example, you might need to use cmake instead of make. Always read the enclosed “README”, “INSTALL” or other documentation provided by the developers, and you won’t go too far wrong.

Mark Lewin Mark Lewin

Mark Lewin has been developing, teaching, and writing about software for over 16 years. His main interest is web development generally and web mapping in particular. He also has a passion for open source and Linux.


  1. There’s even a two-step proccess to compile a GNU/Linux program from source:

    1. Install Gentoo GNU/Linux;
    2. #emerge your-program.


  2. Check for dependencies (./configure) and compilation (make) do not require super user access. Installation (make install) neither if the ./configure step set the prefix to folder where user can write.

    Like this:
    ./configure –prefix=/home/me/my-prog
    make install

  3. Good article, overall. Perhaps in a future article the author could go over the really complex bit, which is resolving dependencies. It’s been the major roadblock to compiling software… for me, at least.

  4. The article makes me think of this line from South Park:

    Step 1: Gather Underwear
    Step 2: ?
    Step 3: Profit!

    “Resolving Depenedencies” is like step 2. You can spend HOURS resolving dependencies and still coming up short. It can be a very painful process. Some dependencies are inside other dependencies. Some dependencies require a library version that’s newer (or in some cases older) than what’s on your system, sometimes you have to download, decompress and then move libraries to places on your system (sometimes different than other flavors of Linux).

    In short, if you DON’T have to compile from source DON’T DO IT. If you have unlimited time on your hands, though, it could be worth a shot….

  5. If I were you I wouldn’t run any commands as root (sudo) if I didn’t have to. There is no reason to run ‘sudo make’ or ‘sudo make clean’. Simply run ‘make’ or ‘make clean’. You only need root permissions to install a compiled application, so then you need to run ‘sudo make install’

Comments are closed.