Compiling Software from Source


Compiling applications from source is not that difficult. Most source code is available as compressed source tarballsthat is, tar files that have been compressed using gzip or bzip. The compressed files typically uncompress into a directory containing several files. It is always a good idea to compile source code as a regular user to limit any damage that broken or malicious code might inflict, so create a directory named source in your home directory.

From wherever you downloaded the source tarball, uncompress it into the ~/source directory using the -C option to tar:

tar zxvf packagename.tgz -C ~/source tar zxvf packagename.tar.gz -C ~/source tar jxvf packagename.bz -C ~/source tar jxvf packagename.tar.bz2 -C ~/source 


If you are not certain what file compression method was used, use the file command to figure it out:

file packagename 


Now, change directories to ~/source/packagename and look for a file named README, INSTALL, or a similar name. Print out the file if necessary because it contains specific instructions on how to compile and install the software. Typically, the procedure to compile source code is as follows:

./configure 


This runs a script to check whether all dependencies are met and the build environment is correct. If you are missing dependencies, the configure script normally tells you exactly which ones it needs. If you have the Universe and Multiverse repositories enabled in Synaptic, chances are you will find the missing software (usually libraries) in there.

When your configure script succeeds, run

make 


to compile the software. And finally, run the following:

sudo make install 


If the compile fails, check the error messages for the reason and run

make clean 


before you start again. You can also run

sudo make uninstall 


to remove the software if you do not like it.

Relevant Ubuntu and Linux Commands

You will use these commands while managing your Ubuntu system resources and software packages:

apt-get The default command-line package-management tool (see Chapter 33 for more on APT)

gnome-app-install The Ubuntu GUI Package Manager

synaptic Advanced tool for software manipulation and repository editing

update-manager The primary source of Ubuntu package updates




Ubuntu Unleashed
Ubuntu Unleashed 2011 Edition: Covering 10.10 and 11.04 (6th Edition)
ISBN: 0672333449
EAN: 2147483647
Year: 2006
Pages: 318

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