Hot Topic #4 , "Compiling programs - How to make it work"
Starting Out: Finding depenencies & Configuring
Environment Variables and Makefiles
Yet more problems?
When I first started out using .tar.gz files I remember having great difficulties in making almost anything compile. It was a real pain to me, as some software that I wanted was not in .rpm format. I had to learn it the hard old way, so hopefully I can alleviate the pressures for you.
Almost every program you install depends upon another program or library. A library is a piece of software that enables a series of functions to happen within a program. For example, all of the software written for the KDE interface depends upon an interface library called QT, which is made by a company called TrollTech. A lot of software written for Gnome uses an interface library called TCL/TK.
These are known as dependencies, but QT and TCL/TK are very basic dependencies. For example, you may want to install something like PGP or SSH, which requires a library called libcrypto.so.0.
The same thing happens with Windows, although it's just a lot more transparent. Ever wonder why you get .DLL errors? .DLL files are what Microsoft term 'Dynamic Link Libraries', which is just a fancy name for a library. When you install a program in Windows, it installs the libraries required too, because most of the time, these libraries come packaged with the software.
Because of the open source nature of Linux, libraries (which are almost always not written by the author of the software you are trying to install) are not packaged with the software you are installing. You need to obtain the extra library before you can install the software that you want to use. This is called a dependency, because one piece of software depends upon another.
To find out what dependencies a particular piece of software has, here are some good places to check:
When you are sure that your system meets all the dependencies, and all the versions of the dependencies are up to date, then quickly read over (or optionally print out) the INSTALL file to check if there are any special requirements to install the software. If the INSTALL file reads something like 'These are generic installation instructions' then you can be pretty sure that that means the standard 3-step installation routine applies:
If you get past the initial ./configure stage, and everything seems to be fine, but then it all dies when you get to the make stage, most of the time, it's best to go over your configure again, and look closely at what it spits out to see if there is anything that you think looks odd. If you are convinced, however, that there is something that you can only fix by editing the result of the ./configure -- the Makefile, then reading the following will help:
You'll find that a lot of tarballs contain extra requirements in their INSTALL files, such as modifying a Makefile when you create it with configure (or otherwise), or checking your system has certain environment variables are set.
Firstly, type set at your command prompt. You'll see a list of every single environment variable that's set. If the instruction in the INSTALL file tells you to define a variable, you can usually do this by typing the following:
export VARNAME="CONTENT"However, most variables are defined within the Makefile, so open up the Makefile, and have a peek in there. There may even be some comments to the effect of 'If you use Linux, uncomment this line, or if you use BSD, use this one'. Comments are delimited by a hash '#' at the start of a line.
Using the GTK+ example again, say your make dies because it can't use libgtk-1.2.0.so.0, and you think it's going to the wrong path to find this library, search through the Makefile, and find all references to GTK. You'll soon find stuff like: GTK_LOCATION='/usr/lib/libgtk-1.2.0.so.0', that's just an environment variable, same as your exported value, if it looks wrong, change it, and go back to the prompt. Type make clean - to clean up the mess it made before on the failed compile, and then type make again. Did it work? Great!, you fixed it. Did it fail? Get to work again!
You've tried doing basic debugging with ./configure, you've edited the Makefile, and still no luck. At this point, I do one or all of the following five things:
If you are continually getting a dependency based problem, and you reckon that you've sorted out the ld.so.cache file and you've got no reason to believe there should be dependency probs, sometimes ./configure is just messing around. Firstly, try removing the file config.cache (which is created the first time you do a ./configure -- that might work. If not, do a ./configure --help and look for anything relating to the error that you get. Again, taking our example of GTK+, I have done this one myself once or twice, with some software that depended on GTK -- which I did indeed have installed:
./configure --help | grep "gtk"
Hopefully you're now pretty good at configuring, so if you get any more problems on a larger scale, it's probably time to start asking people in places like our Forum