Tutorial Index

Tutorial 1 - Library Installation


Introduction

This tutorial provides an example of how to download and install the SDL and OSG libraries in a Linux environment. The following link provides instruction for installation in a Windows environment: Windows install.

The following link provides additional instruction for Ubuntu:
Ubuntu install.

Concepts

SDL and OSG Library Installation
Command Line Instructions

Preparation

We describe the process of installing from source. However, you may want to install from the binary versions of the libraries because there are a lot of dependencies on other libraries. As a launching point from which we can perform the installs, we'll create a directory for our project called game_engine, in a directory of your choosing:

> mkdir ./game_engine

Next, we create a temporary installation directory to house our installation source packages.

> mkdir ./game_engine/inst_sources/

Note that in the following examples, to perform the final step for installation of a library, a 'make install' is usually performed. This step can only be performed with root privileges. This step will fail if performed as a regular user and the corresponding library will not be integrated into the system's library. Thus a 'sudo' (or 'su') should be performed with the 'make install' step to temporarily change to root user.

Installing the Source Packages

We will first provide instructions for SDL, and then for OSG.

SDL:

We need 4 specific source packages for our SDL installation:

SDL Source - SDL core library
SDL Image Library - SDL Image manipulation library
SDL Mixer - SDL audio mixing library
SDL TTF - SDL TrueType Font support library

Let's create a directory for SDL inside of our inst_sources folder:

> cd ./game_engine/inst_sources/
> mkdir ./SDL/

Downloading

The 4 files need to be downloaded into the SDL directory we just created.

SDL Source
SDL Image Library
SDL Mixer
SDL TTF

Alternatively, you could obtain these files with the command 'wget' in the following manner:

> wget http://www.libsdl.org/release/SDL-1.2.11.tar.gz
> wget http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.8.tar.gz
> wget http://www.libsdl.org/projects/SDL_mixer/release/SDL_mixer-1.2.7.tar.gz
> wget http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.5.tar.gz

Compile/Install Sources

Now that you have the source packages in the correct folder, you need to compile them and integrate them with your existing library folder. Note that the commands should be performed starting in the SDL folder.

SDL Source:

> gunzip ./SDL-1.2.11.tar.gz
> tar -xf ./SDL-1.2.11.tar
> cd ./SDL-1.2.11
> ./configure
> make
> sudo make install
> cd ..

SDL Image Library:

> gunzip ./SDL_image-1.2.5.tar.gz
> tar -xf ./SDL_image-1.2.5.tar
> cd ./SDL_image-1.2.5
> ./configure
> make
> sudo make install
> cd ..

SDL Mixer:

> gunzip ./SDL_mixer-1.2.7.tar.gz
> tar -xf ./SDL_mixer-1.2.7.tar
> cd ./SDL_mixer-1.2.7
> ./configure
> make
> sudo make install
> cd ..

SDL True Type Font:

> gunzip ./SDL_ttf-2.0.8.tar.gz
> tar -xf ./SDL_ttf-2.0.8.tar
> cd ./SDL_ttf-2.0.8
> ./configure
> make
> sudo make install
> cd ..

Cleaning Up

Now that the SDL packages are installed, you have the choice of cleaning up, i.e., keeping the installation source files, or removing all of the source files. If you choose to remove the source files, you should go to: >/game_engine/inst_sources/SDL/ folder:

Note: be EXTREMELY careful with the following command because it will remove everything in the current directory and in all subdirectories. Also, make sure you're not in your root directory:

> rm * -rf

If you executed this command in the right place, your SDL directory should now be empty, and cleanup is complete. If you executed this command from the wrong directory, you are probably wishing that you had never seen this tutorial!
In the future, if any updated packages are released for SDL, they may be placed here in the SDL directory and installed using the process you just followed.

OSG:

For OSG, you need only download a single file. Like SDL, you might first create a base folder in which to place your source package. From the inst_sources folder:

> mkdir ./OSG/

Downloading

We need to place the following file into the OSG directory we just created:

OSG Source

or use the command 'wget' to obtain the file from within our OSG directory:

> wget http://www.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-2.2.0.zip

Compile/Install Source

The commands should be performed starting in the OSG folder. Like SDL, we have to compile this package. We do so by running the following commands:

Uzipping Package

> unzip ./OpenSceneGraph-2.2.0.zip > cd ./OpenSceneGraph-2.2.0.zip

Installing OpenThreads

> cd ./OpenThreads
> make
> sudo make install
> cd ..

Installing Producer

> cd ./Producer
> make
> sudo make install
> cd ..

Installing OpenSceneGraph

(Note: 'make' will likely take a long time to complete on most systems.)

> cd ./OpenSceneGraph
> make
> sudo make install
> cd ..

Cleaning Up

Now that you have finished installing the OSG packages, you have the choice of leaving the source installation files as they are, or remove (clean up) all source files. If you choose to clean up, as before, while in the <location>/game_engine/inst_sources/OSG/ folder:
(Note: be EXTREMELY careful with the following command because it will remove everything in the current directory and in all subdirectories. Also, make sure you're not in your root directory)

> rm * -rf

If you executed this command in the right place, your OSG directory should now be empty, and cleanup is complete. In the future, if any updated packages are released for OSG, they may be placed here and installed in a similar fashion to those just installed.

Generic Linux Installation Scripts

The following scripts will automate the process of installing the necessary components to complete the tutorial sets found herein. Note that these scripts may not work for everyone, they are provided only as a convenience for those who are unable to manually install the packages. We cannot be held responsible for the damage that may be caused to your system via the use of the following scripts. Note that you will need superuser privileges during some portions of these scripts. Run the scripts in the order they are presented here. This may be accomplished by typing 'sh ./scriptname.sh'.
1. Download Script
2. Install Script

Reference Links

Other helpful links, such as the SDL and OSG home pages, can be found in the links section.

Conclusion

Hopefully at this point you've been successful in installing both SDL and OSG. If not, try repeating all of the steps from the beginning, it's easily possible to miss a step. At this point, you're ready to begin coding using the new libraries, which we will explain in the next tutorial.