Compiling a program from source

Compiling a program from source is usually fairly easy. Programs thatdon't use GNU makefiles, however, can cause trouble.

1. Set up a proper build environment.

To automatically install the software needed to compile most programs, simply run apt-get install build-essential. This will ensure that GCC and the standard C libraries are available.

2. Extract the source package.

Source code is usually distributed in a tarball (a .tar.gz file). To extract it, run:

tar xvvf nameofprogram.tar.gz

This will extract the source code into a directory, usually with the name and version of the program (ie. qemu-9.0.4). Change to this directory.

3. Run the configure script

Run the configure script in the source directory by typing ./configure

This script will check your build environment and make sure you have all needed libraries. If it is missing any, it will prompt you to install. The configure script will also often allow you to choose various build options. You can view these options by running ./configure --help. After it is run, it will generate the necessary makefile.

4. Run 'make'.

This is what launches the build process. Simply type make, and the program will start to compile. Providing everything goes well (some programs work better than others), the program should compile. Ifit doesn't, read the error messages carefully to find out what went wrong.

5. Install it.

To install the program, simply run make install as root. This should install the program under /usr/local/bin. You can then launch it by typing the name of the binary.