Compiling Software from Source


Some programs are too complex or too specialized for the programmer to go to the trouble of creating RPMs for them. So the programmer archives the source code in a tarball and sends it out. Often, simply extracting the code into an appropriate directory is all that's needed to make the application work, as you've seen with several of the blogging tools in Chapter 14, "Creating Basic Websites," and the Azureus BitTorrent client in Chapter 17, "Secure File Transfer."

Other programs must be compiled before they can work. This section will help you do this. Before beginning, you will need to have the GNU Compiler Collection (gcc) installed to handle this task.

First, when compiling new source code, create a new subdirectory in your home directory called source. This will let you compile your code as a user and help prevent any bad (or even malicious) code from harming your system.

Now the task is to extract the archive into the new ~/source directory. You can do this in GNOME File Roller or Ark for KDE, but it will be faster from the shell. Change directory to the ~/download folder (or wherever your source archive is sitting). Depending on the archive format of the original file, type one of the following commands:

tar xzvf <package>.tgz -C ~/source tar xzvf <package>.tar.gz -C ~/source tar xjvf <package>.bz -C ~/source tar xjvf <package>.tar.bz2 -C ~/source 

The first two are different extensions for a tar/gnuzip archive, whereas the last two were archived using BZip. The -C switch extracted the archived files to the ~/source directory. If you are not sure what archiving method was used, use the file command to help you determine the format. Type file <package>.

Now change to the extracted program directory under the ~/source directory. Look for a file (usually named in ALL CAPS so you can find it better) called something like README or INSTALL. This file will have detailed instructions on how to compile and make the program work. Chances are these instructions will be some variation on the Configure/Make/Make Install process. This means you will first run a script called configure, as follows:

./configure 

This script confirms that all dependencies are met and the build environment is solid. When this script runs successfully, compile the program with the make utility included in gcc:

make 

Finally, log in as the SuperUser and install the program with the same make utility:

make install 

This should safely install your new source program.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net