Skip to content

Instantly share code, notes, and snippets.

@thilong
Created March 6, 2020 10:09
Show Gist options
  • Save thilong/709661a75217f34c51f61c8e1821e0e2 to your computer and use it in GitHub Desktop.
Save thilong/709661a75217f34c51f61c8e1821e0e2 to your computer and use it in GitHub Desktop.
Compile SDL2 from source
Compile SDL2 from source
Christer Solskogen edited this page 21 days ago · 31 revisions
Note - If you are running on Raspbian Buster Desktop
The instructions below are no longer needed with the latest version of Raspbian Buster, if you are running under the full Desktop. You can just install the SDL2 packages from the official repository in that case, using the following:
sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev
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 Buster 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 might have some 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. Keep in mind that the Legacy driver does not work on Raspberry Pi 4.
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 libdrm-dev libgbm-dev libudev-dev libasound2-dev liblzma-dev libjpeg-dev libtiff-dev libwebp-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.10.tar.gz
tar zxvf SDL2-2.0.10.tar.gz
cd SDL2-2.0.10
./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.5.tar.gz
tar zxvf SDL2_image-2.0.5.tar.gz
cd SDL2_image-2.0.5
./configure && make -j $(nproc) &&
sudo make install
...and SDL2_ttf:
cd ~
wget https://libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz
tar zxvf SDL2_ttf-2.0.15.tar.gz
cd SDL2_ttf-2.0.15
./configure && make -j $(nproc) &&
sudo make install
sudo ldconfig -v
@MarioMaliqi
Copy link

bruh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment