Installing Software Packages — Part III

We looked at source code and some of the basic tools used for working with source code last month. In this month's column, the last of our three-part series on dealing with source releases, we'll look at how to install a source release using the game XPilot as an example. Once you've mastered the procedure for installing a source release, you'll have access to many useful and fun programs that are not yet available in binary form. So, roll up your shirtsleeves, and let's get to it.

Newbiew Screenshot 1
Figure One: The XPilot Game is like Asteroids on steroids.

We looked at source code and some of the basic tools used for working with source code last month. In this month’s column, the last of our three-part series on dealing with source releases, we’ll look at how to install a source release using the game XPilot as an example. Once you’ve mastered the procedure for installing a source release, you’ll have access to many useful and fun programs that are not yet available in binary form. So, roll up your shirtsleeves, and let’s get to it.

The XPilot Game

The increasingly popular game XPilot is a multi-player, network game that lets you pilot a spaceship. Think of XPilot as Asteroids on steroids, with ship-to-ship combat thrown in. Bjorn Stabell and Ken Ronny Schouten, who were undergraduate students at the University of Tromso in Norway, originally wrote the game. It is available at http://www.xpilot.org/. Figure One shows a typical game screen.

To install the source release of XPilot, we’ll follow these steps:

  1. Install the compilation toolkit
  2. Download the source
  3. Uncompress and unpack the source
  4. Read the instructions
  5. Configure compilation options
  6. Compile the program
  7. Install the program

Install the Compilation Toolkit

To install a source release, you’ll need several tools. Here are the tools most likely to be needed and the names of the Red Hat Linux packages that contain them:

  • C compiler: egcs
  • C preprocessor: cpp
  • The make utility: make
  • Support utilities: binutils
  • Header files: kernel-source, glibc-devel
  • X development utilities and headers: XFree86-devel

All these tools are included on the standard Red Hat Linux CD-ROM, and we talked about what they all do in last month’s column. To install the tools, mount the Red Hat Linux CD-ROM, move to its RedHat/RPMS directory and issue the RPM command:

mount -t iso9660 /dev/cdrom
/mnt/cdrom -o ro
cd /mnt/cdrom/RedHat/RPMS
rpm -Uvh egcs-*.rpm cpp-*.rpm
make-*.rpm binutils-*.rpm
kernel-source-*.rpm glibc-
devel-*.rpm XFree86-devel-

If you get a dependency error or errors, you may need to install additional packages.

Download the Source Code

You can download XPilot by using a Web browser (which is the easiest way) or an FTP client. The URL for the source release is ftp://ftp.XPilot.org/pub/XPilot/XPilot-4.2.1.tar.gz. If XPilot isn’t your notion of the ideal game, you can find g’zillions of other games on the Web at http://freshmeat.net/appindex/x11/games.html. Like XPilot, many of these games are distributed only in source form.

Note: If you want to play XPilot without coping with the source release, you’ll find an older version of the program on the Red Hat Linux CD-ROM. However, that would take all the fun out of it.

Uncompress and Unpack the Source Code

Like most source releases, XPilot is distributed as a so-called tar ball (named for the program you must use to uncompress and unpack it). You can generally recognize a tar ball by its name, which typically ends in .tar.gz or .tgz. To uncompress the XPilot tar ball, issue the command:

tar zxf xpilot-4.2.1.tar.gz

Releases may be distributed in a format other than a tar ball (for example, .zip files are also popular). Again, see last month’s column for more instructions on coping with these files.

Read the Instructions

When you uncompress and unpack a tar ball, it generally creates a directory with the same name as the original tar ball without the .tar.gz or .tgz extension. Find the name of the new directory by issuing the ls command, as shown in Figure Two. Then, move into the new directory and list its contents, as shown in Figure Three.

Figure Two: Finding the New Directory

[bmccarty@athlon bmccarty]$ ls
Desktop mail mbox

Figure Three: Moving to the New Directory

[bmccarty@athlon bmccarty]$ cd xpilot-4.2.1
[bmccarty@athlon xpilot-4.2.1]$ ls
INSTALL.txt LICENSE Local.rules README.txt
Contrib lib Imakefile Local.config
README.OS2 README.txt.msub doc

A source release will almost always contain text files that explain how to install the program. Look for files with names like README or INSTALL. Sometimes, the files may reside in a subdirectory, so be diligent. When you find a file, read it or, better yet, print it:

lpr INSTALL.txt

From this point forward, it’s best to follow the instructions that accompany the source release. However, most source releases are installed pretty much the same way, so I’ll present a generic approach.

Configure Compilation Options

The next step is to specify compilation options (not to be confused with complication options, however strong your feelings in the matter). Look in the directory that contains the source release for a file named Imakefile or Makefile. If you find Imakefile, issue the command:

xmkmf -a

This command should produce gibberish-like output similar to what you see in Figure Four. Hopefully, the gibberish contains no serious errors.

Figure Four: Configuring XPilot

[bmccarty@athlon xpilot-4.2.1]$ xmkmf -a
imake -DUseInstalled -I/usr/X11R6/lib/X11/config
make Makefiles
making Makefiles in doc…
(many lines omitted)
make[1]: Leaving directory ‘/home/bmccarty/XPilot-4.2.1/src’
[bmccarty@athlon xpilot-4.2.1]$

If you find Makefile, you’ll often also find a file named configure. If so, issue the command:

./configure -prefix=/usr

If they happen to be included, both the Imakefile and the configure file are there to assist in setting things up so that the program you are about to compile will, in fact, compile and install smoothly on your machine. If you find Makefile, but not configure, you don’t need to do anything.

Compile the Program

Now, you’re ready to actually compile the program. The road forks a bit here. Any of several commands may be the proper next step:

  • make
  • make all
  • make program, where program is the name of the program you want to compile.

Try them in the order listed. If you get a message saying that make can’t continue, try the next command. If none of these commands works, it’s time for ET to phone home: Seek help via IRC chat, a Web forum, a newsgroup or e-mail the program’s author. Figure Five shows the compilation of XPilot.

Figure Five: Compiling XPilot

[bmccarty@athlon xpilot-4.2.1]$ make
rm -f README.txt
./contrib/msub/msub+R”@<”-R”>@” README.txt.msub >README.txt
making all in ./doc…
(many lines omitted)
make[1]: Leaving directory ‘/home/bmccarty/xpilot-4.2.1/src’
[bmccarty@athlon xpilot-4.2.1]$

Install the Program

If the compilation completed without errors, you’re ready to install the program. It is worth pointing out that while errors are generally serious, a few compiler warnings probably won’t ruin your day. Don’t worry too much about them if you see a few.

To install the program, issue the commands:

make install

The su command gives you temporary root privileges (which you will need in order to install any software on your system), and the exit command restores your status as an ordinary user. Figure Six shows the installation of XPilot.

Figure Six: Installing XPilot

[bmccarty@athlon xpilot-4.2.1]$ su
Password: (password not echoed)
[root@athlon xpilot-4.2.1]# make install
installing in ./src…
make[1]:Enteringdirectory ‘/home/bmccarty/xpilot-4.2.1/src’
(many lines omitted)
make[1]: Leaving directory ‘/home/bmccarty/xpilot-4.2.1/lib’
install in . done[root@athlon xpilot-4.2.1]#


Now, at last, you’re ready to play. XPilot requires you to run two programs simultaneously:

  • XPilot, the game server
  • XPilot, the game client

If you think you’re seeing double, you’re not. The XPilot command to start a client is the same as that to start a server. If you scrutinize the output of the installation process, you can determine that it placed the binary files in /usr/local/games/bin. To start the server, issue the following commands in an X terminal window:

cd /usr/local/games/bin

To start the client, issue these commands in a second terminal window:

cd /usr/local/games/bin

If all is well, you’ll see the game screen shown as Figure One . All that remains is learning how to survive flying debris and opponents!

Now that you know how to cope with source code, check out http://www.freshmeat.net, download some source releases and compile them. The generic instructions I’ve given won’t work for every release, but you should succeed much more often than you fail. If you do fail, read the documentation that accompanies the release, which should set you straight. Soon, your hard drive will be bursting its cylinders to hold all the source releases you’ve downloaded and compiled.

Next month, I’ll explain how to mount filesystems so that you can use removable media in order to store all the software that you’ll accumulate. Until then, happy compiling.

How to Install a Source Package

In this series, I’ve mentioned binary packages and source releases. There’s a third species that I’ve glossed over: source packages. A source package is a package that contains source code. Just as ordinary packages make it convenient to download and install binary code, source packages make it convenient to download and install source code.

You can recognize an RPM source package by its name. For example, the package file xfishtank-2.0-14.rpm contains the binary release of the xfishtank program, while xfishtank-2.0-14.src.rpm contains the source release of the xfishtank program (the .src.rpm suffix is the giveaway here). You can install an RPM source package by issuing the same command used to install an ordinary package. For example, you can install the xfishtank source package by issuing the command:

rpm -Uvh xfishtank-2.0-14.src.rpm

When you install an RPM source package, its files are placed in /usr/src/redhat/SOURCES. There, you’ll find a tar ball containing the source code. You’ll often find patches and other auxiliary files as well.

Bill McCarty is an associate professor at Azusa Pacific University. He can be reached at bmccarty@apu.edu.

Comments are closed.