InstallTarball
From Berkshire Linux Users Group
Contents |
Introduction
This a beginners guide to installing software from a tarball under Linux. The tarball can be any archive (*.tar.gz, *.tar.bz2, *.zip) direct from the developers. This is generally something you want to avoid, as it is best to install software from your distribution's package manager. Installing software this way can be easy to loose track of and difficult to upgrade. But sometimes there is software that just isn't available from your distributions package manager.
(note to self, describe a bit more of the software release process)
Quickstart
If you just want to dive right in and breeze through it, 90% of the time you can just run the following commands once you've download your software.
# tar -xzvf package-version.tar.gz # cd package-version # ./configure # make # make install
If you want to get to know the process a bit more, be able to handle oddities, or modify the build process read on.
Find the Tarball
Generally you will find the tarball you're looking for at the softwares primary website. A good place to start is Source Forge, FreshMeat, or Google.
Unpack the Tarball
Once you download and locate your tarball, you need to unpack it.
To unpack *.tar.gz run:
# tar -xzvf [filename]
To unpack *.tar.bz2 run:
# tar -xjvf [filename]
To unpack *.zip run:
# unzip [filename]
Then cd into the new packge directory, usually just * part of the previous filenames.
Anatomy of a Tarball
Most tarballs follow a pretty standard package format made common by the GNU project and their development utilities (gcc, automake, autoconf). The following is a list of important files/directories:
- INSTALL -- contains installation instructions
- README -- contains information about the software
- autogen.sh -- build script to generate build files
- configure -- script to configure / check build environment
- Makefile -- rules on how to build the software
- doc/ -- documentation
- src/ -- source files
Read Up
The first thing you should do once you unpack your software is read the INSTALL and README documents. While with most packages you can autopilot through the build process, some have little quirks or special information for the package. This could tell you that the build process may not follow the standard GNU make conventions. Maybe there is a special build script you need to run. Or it could describe some important configure options. So ALWAYS READ THE DOCUMENTATION.
Building the Package
Now that you know more about the software and the installation procedure, you can start building. I will describe the basic steps involved.
Generally the configure and Makefile files are automatically generated by the build system. The configure script may be there, but the Makefile will most likely not. The relationship is the autogen.sh file generates the configure script, and the configure script generates the Makefile.
Running autogen.sh
If your configure script is not available, run the command:
# ./autogen.sh
Otherwise, just skip to configure. Note that ./autogen.sh will probably run the configure script once it's done, and in my experience any commands passed to autogen.sh will be passed to configure. So read the Running configure section before running ./autogen.sh.
Running configure
Most packages, before they can be installed, need to be configured. But if you see a Makefile in your package root then you probably can skip this step. The configure script does a lot of important stuff like determining where to install the package files and make sure the dependencies are available on your system. From the command line run:
# ./configure
This will select the default set of options. For a listing of package specific options run:
# ./configure --help
The most common use of the configure script options is to specify the install prefix. This is done with the command:
# ./configure --prefix=/usr/local
I find /usr/local to be a good place for manually installed packages since it is out of the way of most distributions packages. Keep in mind that there are some important paths which determine where certain files can be found which must be accessible through the prefix. The most important is the environmental variable PATH. If you are using a non-standard install prefix you can set this up in your ~/.bashrc.
You can also specify optional features for the package here. Read the INSTALL or README documentation for information on what features are available.
The configure script will take a while to run, and you will see a lot of things like:
Checking for xxx ... found
If the configure script fails, usually on a missing or incompatible version of a library, you will have to install it, preferably from your package manager, and re-run configure.
Once this is done it will create/overwrite the Makefile for the package.
Running Make
Now that you have your build environment setup and your Makefiles available, you can begin building and install the software. This is pretty simple, just run:
# make
This will compile all the code for the software. It is the most time consuming process, taking anywhere from 30 seconds to 30 hours depending on the size of the package and speed of your system.
This is the most likely place where errors can occur. But keep in mind that usually it is a problem with your build system and not the software itself. So don't go right to the developers saying their software is broken unless you've done your homework and are sure. The software wouldn't be released if the they couldn't compile it. And you're not the only one who has tried to compile it before, so you should start by googling the error. If you can't find any answers, feel free to contact the BLUG or the software's user community or developers, just don't tell them their software is broken. If you know a bit about software development, it is a good idea to try and dig into the error to see if you can solve it yourself.
Once it is done compiling successfully you can install the software using the make command:
# make install
Note that you will most likely have to be root to be able to write the files to their destination (determined by the configured prefix). So if you are not root already you will probably have to run:
# su # make install # exit
This will install the software to the install prefix, generally /usr/local.
It will generally install the package files to the following locations below your prefix:
- [prefix]/bin -- executables, what you actually execute to run the software
- [prefix]/doc -- software documentation.
- [prefix]/include -- any include files so you can compile software against the software's libraries.
- [prefix]/lib -- any shared libraries used or provided by the software
- [prefix]/man -- manual pages. This is so you can run man [man page].
Conclusion
Now you're pretty much done. You can check to make sure your software works by running one of the executables.
