Compile SDL2 from source

Dimitris Panokostas edited this page Jan 1, 2019 · 23 revisions

If you want to run the SDL2 version on the Raspberry Pi, you currently need to compile SDL2 from source in order to get support for launching full screen applications from the console. Unfortunately, the version bundled with Stretch is not compiled with support for the "kmsdrm" backend, so it only works under X11 (which may be fine for you, but keep in mind that you'll have lower performance).

Important note:

It's recommended that you use the "fkms" video driver on the RPI, to be able to use both the "KMSDRM" backend and "Dispmanx" at the same time. If you're still using the Legacy driver, it's probably better to stick to the SDL1 + Dispmanx version. If you have the full KMS Driver activated instead, then you cannot use any Dispmanx target since that is disabled with that video driver automatically.

Currently, the best-performing version on the RPI, is one using the DispmanX back-end with SDL2 (configured for KMSDRM).

Follow these steps to download, compile and install SDL2 from source:

sudo apt-get update && sudo apt-get upgrade

(Minimal requirements)

sudo apt-get install libfreetype6-dev libgl1-mesa-dev libgles2-mesa-dev libgbm-dev libudev-dev libasound2-dev liblzma-dev git build-essential

(...or for the full list of requirements, also add the below)

sudo apt-get install gir1.2-ibus-1.0 libdbus-1-dev libegl1-mesa-dev libibus-1.0-5 libibus-1.0-dev libice-dev libsm-dev libsndio-dev libwayland-bin libwayland-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxss-dev libxt-dev libxv-dev x11proto-randr-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xinerama-dev

cd ~
wget https://libsdl.org/release/SDL2-2.0.9.tar.gz
tar zxvf SDL2-2.0.9.tar.gz
cd SDL2-2.0.9
./configure --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-video-rpi &&
make -j$(nproc) &&
sudo make install

Next, we need SDL2_image:

cd ~
wget https://libsdl.org/projects/SDL_image/release/SDL2_image-2.0.4.tar.gz
tar zxvf SDL2_image-2.0.4.tar.gz
cd SDL2_image-2.0.4
./configure && make -j $(nproc) &&
sudo make install

...and SDL2_ttf:

cd ~
wget https://libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
tar zxvf SDL2_ttf-2.0.14.tar.gz
cd SDL2_ttf-2.0.14
./configure && make -j $(nproc) &&
sudo make install

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.