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





Copyright @ 2007 OpenSourceProject.org.cn.部分作品为网上收集整理,供开源爱好者学习使用,如侵犯了您的权益,请联系chinaperl@gmail.com,本站将立即删除。