| Games and SDL SDL Installation SDL for Embedded SDL API SDL Events | SDL Graphics SDL Threads Thread Example SDL Animation SDL Sound | Raw Video Player Video Formats Video Compression | Game Trees About The Author |
SDL Installation
Most likely, your Linux system already has SDL and related packages installed. In cases your system does not have or you want to upgrade the packages, you can download them directly from the site SDL site ( http://www.libsdl.org ). More precisely, the packages can be found at the following links.
The installation processes of the above packages are all very similar to each other. We'll use the SDL-1.2.11.tar.gz package as an example to illustrate the steps. First, you can browse the sites and download the desired packages by clicking on their links. Or more conveniently, you may use the wget command to acquire it; you first go to a directory and issue the command
where url is the URL link to the package. For example, the following command
downloads the SDL package into your desired directory, say, /download. ( You may obtain the complete URL of the package by first using a browser to access the page containing a link to it and pointing at it with the mouse; pressing the right button of the mouse let you choose to copy the link. ) You can then implode it into another directory by
You should find the files "README" and "INSTALL" in the directory. Read the files to obtain the information of installation. If you simply plan to use the default setting, the following three commands will do the job.
|
$./configure
$make #make install |
The command configure set up the installation directories and the optional features of of the package. As no arguments are provided, default settings will be used. The SDL library will be installed in the directory /usr/local/lib. After make install the library is ready for use; you need to include <SDL/SDL.h> in your program and link it with -lSDL when compiling your application. If you want to find out other options that you can have, use the command
and scroll through the menu displayed.
Nowadays, the most popular embedded processors are the ARM processors ( http://www.arm.com ). Over the last decade, the ARM architecture has become the most pervasive 32-bit architecture in the world, with more than 2 billion ARM-based processors shipped. Throughout this book, our discussion involved embedded systems will be centered around the ARM processor core. There are two commonly used compilers for ARM processors, namely, arm-elf-linux-g++ for ARM 7 products and arm-linux-g++ for ARM 9 products.
Though the installation of SDL packages to be used for embedded systems is similar to the case for PC, very often we need to do some customization of selected features when doing configure. A convenient way to handle this is to write a simple script to set the desired configuration choices. Suppose, without loss of generality, we want to install all the SDL libraries for ARM processors in the directory /arm. The following is a sample script, named arm_configure.sh to handle this.
#!/bin/sh
export INSTALL_PATH=/arm
if [ $1 ]
then
#for ARM7
export USER_HOST=arm-elf-linux
export USER_CROSS_COMPILE=arm-elf-
else
#for ARM9
export USER_HOST=arm-linux
export USER_CROSS_COMPILE=arm-linux-
fi
export USER_CFLAGS="-I${INSTALL_PATH}/include/"
export USER_LDFLAGS="-L${INSTALL_PATH}/lib/"
export USER_CC="${USER_CROSS_COMPILE}gcc"
export USER_CXX="${USER_CROSS_COMPILE}g++"
export USER_AR="${USER_CROSS_COMPILE}ar"
PRIV_FLAGS=
if [ ${USER_HOST} = "arm-linux" ]
then
PRIV_FLAGS="-DDISABLE_MOUSE -D__ARM__"
elif [ ${USER_HOST} = "arm-elf-linux" ]
then
PRIV_FLAGS="-DDISABLE_MOUSE -D__ARM__"
fi
#PRIV_FLAGS="-D__ARM__ -DFBCON_DEBUG"
./configure \
--prefix=${INSTALL_PATH} \
--host=${USER_HOST} \
--enable-static \
--disable-shared \
--disable-joystick \
--disable-cdrom \
--disable-esd \
--disable-nasm \
--enable-video-fbcon \
--enable-video-opengl \
--enable-osmesa-shared \
--disable-arts \
--disable-alsa \
--without-x \
--enable-debug \
--enable-loadso \
CC=${USER_CC} \
CXX=${USER_CXX} \
CFLAGS=" ${USER_CFLAGS} ${PRIV_FLAGS} -DFBCON_DEBUG -DNO_SIGNAL_H " \
LDFLAGS=${USER_LDFLAGS}
make
make install
|
Note that in the script, we have disabled the mouse meaning that we won't use any mouse in the ARM board. Of course, this would not make your embedded programs very interested. If we want to enable the mouse or touch-screen feature for an ARM board, which usually does the interface via the USB port, we need to do some modifications to the SDL files. We will discuss this in later chapters.