Doug's Linux Notebook

Compiling Software in Linux

It is good to know how compile software from source if you can't find what you need in a package. The steps are the same for all Linux distro's.

The first step is to obtain the program to be installed, probably by downloading from the internet. Source files have names that end with .tar.gz

I have made a sub directory named "build" under /usr/src where I usually unpack and compile (or build) all my new software, this way things are neat and organized. Some Linux distributions already have a sub directory named packages or source or something similar that you could use. Move the source file (sometimes called a tarball) to /usr/src/build or where ever you want to unpack and compile it, it doesn't matter where, and unpack it.

[doug@linux]$ cd /usr/src/build
[doug@linux]$ mv /path/to/program-0.0.0.tar.gz ./
[doug@linux]$ tar xvzf program-0.0.0.tar.gz

You will see file and directory names scroll by on the screen as the source is unpacked. when done you will find a new directory probably with a name similar to the name of the tarball, do an "ls" to see it, this directory is known as the source tree for the software you are going to compile, cd into that directory and do another "ls" and use "less" to read any files named README or INSTALL for instructions and info.

[doug@linux]$ ls
[doug@linux]$ cd ./program-0.0.0
[doug@linux]$ ls
[doug@linux]$ less README

Normally the next step is to run the configure script, you may pass any options from the readme files such as --prefix=$ to install in a directory other than the default. for example "./configure --prefix=/home/Doug" to install in Doug's home directory. I rarely use --prefix or other options, most times I just go with the defaults.

There will be allot of stuff scroll by when configure is run, sometimes it may end with an error telling you that it needs some other program or library or that it can't find something, these problems will need to be fixed then try ./configure again. Next run "make" then "make install" and if there are no errors your new software is installed.

[doug@linux]$ ./configure
[doug@linux]$ make
[doug@linux]$ make install

Note that you may need to be root for the "configure" and "make" steps and will certainly need to be root for "make install".

Always read the INSTALL and README files because they will inform you of any variation from the above procedure.

Back to the Main Page