Download macOS MAME

Ver. 0.210
Upd: May 30, 2019

SDL2 2.0.8 on Raspberry Pi

Updated: 2017.11.30 to cover SDL2 2.0.8 and the latest versions of the utility libraries

With the release of Raspbian Stretch, quite a lot has changed. One of those things is the default graphics drivers for the VC4. This matters to us because with the release of Stretch they have finally removed the old drivers which have been been installed by default as well.

SDL2 is now installed by default but it is compiled for desktop users with support for X and OpenGL, neither of which we can take advantage of in a framebuffer and it will just confuse MAME if you try to compile using it. Just as a test I compiled a minimal MAME 0.188 using the default SDL2 and running on the Desktop I got ~3fps running Gridlee in a window.

So first things first you will need to get rid of the default SDL2

sudo apt-get remove -y --force-yes libsdl2-dev
sudo apt-get autoremove -y

Next we need to set up the build environment; so add a few needed packages

sudo apt-get install libfontconfig-dev qt5-default automake mercurial libtool libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev libudev-dev libtiff5-dev libwebp-dev libasound2-dev libaudio-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxss-dev libesd0-dev freeglut3-dev libmodplug-dev libsmpeg-dev libjpeg-dev

I’m going to assume you use some form of  ‘code’ or ‘develop’ type folder structure for your programming efforts (I use ‘code’, just substitute your development directory structure for mine)

cd
mkdir code
cd code

Now we have need to get the latest build of from the libsdl mercurial by typing:-

hg clone http://hg.libsdl.org/SDL
cd SDL

You will end up with a copy of the SDL2 source code and leave yourself in the source folder.

Now we need to actually build it.

./autogen.sh
./configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-opengl --host=arm-raspberry-linux-gnueabihf
make
sudo make install

That will take a little while but when it’s done if you type sdl2-config --version it should say 2.0.8.

Great success!

Next up we will build all the utility libraries, starting by downloading them all.

cd
cd code
wget http://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.2.tar.gz
wget http://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.2.tar.gz
wget http://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz
wget http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz

Uncompress them all

tar zxvf SDL2_image-2.0.2.tar.gz 
tar zxvf SDL2_mixer-2.0.2.tar.gz 
tar zxvf SDL2_net-2.0.1.tar.gz 
tar zxvf SDL2_ttf-2.0.14.tar.gz

Build the Image file loading library

cd SDL2_image-2.0.2 
./autogen.sh 
./configure 
make 
sudo make install
cd ..

Build the Audio mixer library

cd SDL2_mixer-2.0.2 
./autogen.sh 
./configure 
make 
sudo make install
cd ..

Build the Networking library

cd SDL2_net-2.0.1 
./autogen.sh 
./configure 
make 
sudo make install
cd ..

Build the Truetype font library

cd SDL2_ttf-2.0.14
./autogen.sh
./configure
make
sudo make install
cd ..

All done. Any program that uses SDL2 to draw to the framebuffer should now be doing it in hardware on the raspberry pis videocore4 using opengles2!

7 thoughts on “SDL2 2.0.8 on Raspberry Pi

  1. It seems like some of these libraries have been updated, for example, SDL2_ttf is now on version 2.0.15.
    Will there be any compatibility issues with these versions?

    1. Generally speaking no. There has been the odd occasion where an SDL update stopped MAME working but the MAME team stay right up to date with all the compile tools so the latest versions are usually the one’s you’d want to use.

  2. Hi, first of all thanks for this guide!
    but when I reach the step to launch this command “hg clone http://hg.libsdl.org/SDL” then Raspbian answer this to me: “bash: hg: command not found”.
    What should I do to go on and skip this issue?
    Iam using raspbian stretsh last version (April 2019) and rapberry pi 3 model b+ .

    1. Follow the instructions. hg is a part of mercurial which the previous instructions had you install.

  3. Hi Choccy,

    No matter what I do, I keep getting:

    INFO: Could not initialize video driver: No available video device

    … whenever I try to run/test a SDL2 based program. No idea what the issue could be.

    Thanks for any help you can provide.

Leave a Reply

Your email address will not be published. Required fields are marked *