Compiling on Linux
Extract SDL, run configure and then make:
tar zxvf SDL-1.2.7.tar.gz cd SDL-1.2.7 ./configure make make install
You may also change how SDL gets compiled by adding options to ./configure. To display what options you can change type in:
Test your install by typing in:
Another way to test how SDL works is to try the test applications:
cd test ./configure make make install ./testalpha ./testbitmap # etc ..
Compiling an SDL application using GCC
- Here is a sample makefile for gcc. It compiles sdltest.c file into a binary called sdltest.
all: gcc `sdl-config --cflags` `sdl-config --libs` -osdltest sdltest
- This makefile compiles two .c files into a binary called sdltest.
all: 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/ld.so.conf, and make sure it contains the line:
As root, run /sbin/ldconfig
Make sure /usr/local/bin is in your execution path:
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:
- which sdl-config
- sdl-config --version
- locate libSDL
- tail config.log