Compiling on Linux


Compiling SDL

Extract SDL, run configure and then make:

tar zxvf SDL-1.2.7.tar.gz
cd SDL-1.2.7

make install

You may also change how SDL gets compiled by adding options to ./configure. To display what options you can change type in:

./configure --help

Test your install by typing in:

sdl-config --version

Another way to test how SDL works is to try the test applications:

cd test
make install
# etc ..

Compiling an SDL application using GCC

Example 1

    gcc `sdl-config --cflags` `sdl-config --libs` -osdltest sdltest

Example 2

    gcc -c `sdl-config --cflags` sdltest1.c sdltest1.o
    gcc -c `sdl-config --cflags` sdltest2.c sdltest2.o
    gcc `sdl-config --libs` sdltest1.o sdltest2.o -osdltest

Note: Makefiles should use tabs instead of spaces unlike here.

If you are using an extra library and find yourself getting compilation errors related to functions not being found you may need to add this to the flags in addition to the ones created by sdl-config. For instance, if you are using SDL_image then add -lSDL_image to the compile command.

I installed SDL from source but can't build or run SDL applications

Edit the file /etc/, and make sure it contains the line:


As root, run /sbin/ldconfig

Make sure /usr/local/bin is in your execution path:

export PATH=$PATH:/usr/local/bin/

Make sure that there aren't any other versions of SDL on your system, and that you have removed any file named "config.cache" from the directory of the software that refuses to build.

If all of the above still don't work, send e-mail to the SDL mailing list with the output from the following commands run from the directory of the software that refuses to build:

FAQ_Compiling_on_Linux (last edited 2008-04-17 08:18:18 by localhost)