(Note that most of this page covers SDL 1.2, and not SDL 2.0. You should consider using SDL 2.0 and not 1.2, which is now unsupported.)
SDL supports all known Linux hardware with GNU libc and kernel version 2.6 or newer.
For the latest information see the page about Installation.
The short answer is use the output of the command "sdl-config --cflags --libs" for SDL 1.2 or "sdl2-config --cflags --libs", for example:
gcc -o test test.c `sdl-config --cflags --libs`
If you are using home-grown Makefiles for your project, you can get the proper CFLAGS and LDFLAGS for SDL by adding the following lines to your Makefile:
SDL_CFLAGS := $(shell sdl-config --cflags) SDL_LDFLAGS := $(shell sdl-config --libs)
If you are using autoconf and automake for your project, you can copy the contents of 'sdl.m4' (sdl2.m4) into your acinclude.m4 file, and then add the following to your configure.in file (for SDL 1.2):
dnl Check for SDL =1.2.0 SDL_VERSION($SDL_VERSION, AM_PATH_SDL, :([*** SDL version $SDL_VERSION not found!]) AC_MSG_ERROR) ="$CFLAGS $SDL_CFLAGS" CFLAGS="$LIBS $SDL_LIBS" LIBS
For SDL 2.0, the
AM_PATH_SDL above will be
SDL_VERSION should also be set appropriately.
You need to install the SDL-devel RPM, available from: https://www.libsdl.org/download.php
There is a bug in the nasm assembler version 0.98 - the version shipped with RedHat 7.1. You should upgrade nasm to at least version 0.98.08. If for some reason you can't upgrade, you can disable the assembly code in SDL by passing "--disable-nasm" to configure when building SDL from source.
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:
You probably have a version of SDL built with aRts sound support, and the KDE libraries are not installed in a system standard location. You need to add the directory containing libartsc.so.0 to the file /etc/ld.so.conf and then run the command "ldconfig". On newer versions of Mandrake, this directory is: /opt/kde/lib
How to set an environment variable depends on your login shell:
For Bourne shell derivatives: (sh, ash, ksh, zsh, bash, etc.)
VARIABLE='value'; export VARIABLE
For C shell derivatives: (csh, tcsh, etc.)
setenv VARIABLE 'value'
SDL doesn't use the X11 video driver if it can't open the X display, and if no other drivers are available, it will report this error. To fix this, set your display environment variable appropriately:
DISPLAY=:0 ; export DISPLAY
setenv DISPLAY :0
If you still have problems, try running xhost + localhost Finally, if all those didn't work, and you built SDL from source, make sure that you have the X11 development libraries installed, otherwise you'll get a version of SDL that doesn't include X11 display support. After you install the X development libraries, you need to "make clean" and then rerun the configure and build process.
Some audio drivers don't properly implement select(). I added a hack to approximate the timing using timing functions, and you can enabled this by setting the environment variable SDL_DSP_NOSELECT to "1". You can also use ESounD or aRts as a high-latency sound server.
As of SDL 1.0.3, you can set the environment variable SDL_FBACCEL to "0".
As of SDL 1.0.4, you can set the environment variable SDL_AUDIODRIVER to "dma".
As of SDL 1.0.8, you can set the environment variable SDL_VIDEO_X11_DGAMOUSE to "0".
As of SDL 1.0.8, you can set the environment variable SDL_VIDEO_X11_MOUSEACCEL to "X/Y", where 'X' is the numerator and 'Y' is the denomenator of the mouse acceleration. For example, if you wanted to set mouse acceleration to 2, you would set the variable to "2/1". By default SDL does not change the current X11 mouse acceleration.
You can disable all YUV hardware acceleration by setting the environment variable SDL_VIDEO_YUV_HWACCEL to "0".
Building SDL: make distclean; ./configure --enable-video-aalib ; make install Running your app: set the environment variable SDL_VIDEODRIVER to "aalib".
Make sure that you have XFree86 4.01 or newer, run the program as root, set the environment variable SDL_VIDEODRIVER to "dga", and use a video card like the Voodoo 3000, Matrox G400, or any other card with a decent DGA driver.
X needs to be able to switch to the desired resolution. For this to work, your monitor must support the resolution, and you need to have the resolution listed in your X server configuration.
The following example is taken from my config for XFree86 4.0.1, but 3.3.x is similar. Note that if your monitor isn't capable of using these video modes, the X server will drop these modes from the list of available video modes. Example:
Section "Screen" Identifier "Screen 1" Device "3dfx" Monitor "Samsung LCD" DefaultDepth 16 Subsection "Display" Depth 8 Modes "1280x1024" "1024x768" "800x600" "640x480" "320x240" ViewPort 0 0 EndSubsection Subsection "Display" Depth 16 Modes "1280x1024" "1024x768" "800x600" "640x480" ViewPort 0 0 EndSubsection EndSection
Note the different entries for 8 & 16 bit screendepth. I.e. the 320x240 resolution is *not* available when X is started with 16bit depth (the default).
To test these entries, restart X after you modified XF86Config and press ctrl-alt-plus and ctrl-alt-minus to cycle through the resolutions. -- contributed by Andreas Umbach
You can install these packages for building SDL 2.0 on Fedora:
sudo yum install rpm-build alsa-lib-devel libX11-devel libXScrnSaver-devel libXau-devel libXcursor-devel libXext-devel libXfixes-devel libXi-devel libXinerama-devel libXrandr-devel libXrender-devel libXxf86vm-devel mesa-libGL-devel pulseaudio-libs-devel
Run the following command:
sudo apt-get build-dep libsdl1.2
Or you can get all the dependencies individually:
sudo apt-get install build-essential mercurial make autoconf automake libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libesd0-dev