ELS Howto: Build From Source


Synopsis

This document explains how to set up your Elemental Linux Server (ELS) system to build software from source code.


Prerequisites

Before starting this document, you should first follow the instructions in the ELS Howto: Kernel Rebuild. Even though you may not want to customize your kernel, many source packages depend upon the existence of certain kernel components in order to build successfully.

You may also want to have access to the ELS Source CD-ROM or the ability to download the .iso image from the ELS Distribution Site.


Building from source

The following steps show how to build a typical GNU package from source code.

  1. Download the latest version of the hello package from ftp://ftp.gnu.org/gnu/hello/
  2. Extract the package into your source directory.
  3. Find out what configuration options are available.
  4. Configure the package according to your needs.
  5. Build the package.
  6. Install the package.

Example

The following example shows how you might build version 2.4 of GNU's hello package.

cd /usr/src
wget ftp://ftp.gnu.org/gnu/hello/hello-2.4.tar.gz

tar -zxf hello-2.4.tar.gz

cd hello-2.4
./configure --help | less

./configure

make

mkdir /var/tmp/hello
make DESTDIR=/var/tmp/hello install

Testing

Provided everything went well, there should be a hello binary installed in /var/tmp/hello/usr/local/bin. Run it by issuing the command /var/tmp/hello/usr/local/bin/hello.

The example below shows a successful test of the hello binary.

cd /var/tmp/hello/usr/local/bin
ls
hello*
./hello
Hello, World!

If you were not able to build the hello package successfully, here are some things to try.

  1. Verify that the command gcc --version runs successfully.
  2. Verify that you can successfully build a Linux kernel.
  3. Try a simpler Hello World program like the following example:
cat <<EOF >hello.c
#include <stdio.h>

int main()
{
  printf("Hello World.\n");
}
EOF

gcc -o hello hello.c