Setting up SDL3 on Linux

I knew it wasn’t going to be easy, but it turned out to be quite a bit more difficult than I thought.
The problem is, unlike SDL2, there are no dev versions of SDL3 etc. yet, so you have to build it from scratch.
I’ll be honest, I’m not sure I could have done it without this GitHub repository. User Ravbug who is very busy person (752 contributions on GitHub in the last year- I tip my hat to him or her!) who provided that repository.
It sets up SDL3, SDL_image, sdl_mixer and SDL_ttf.
Follow his link to the Wiki page Scroll down to the bottom for the Linux instructions. I can confirm that it works on Raspberry Pi as well. You’ll need to install cmake first with
sudo apt install cmake
Then run his cmake to build everything and go for a coffee.
Now go into the build folder under sdl3-sample and do
make
That only takes a second or so.
After you’ve done that you’ll end up with a load of files including an executable sdl-min that you can run. That’s what generated the Tiger’s head – it plays The Sting film’s theme (The Entertainer) music as well demonstrating that it’s using SDL_mixer as well as SDL3 and SDL_ttf (I’m guessing) and of course SDL_image.
But that is just the start
To use SDL3 etc in your C program, you need a bit more configuration than with SDL2. I’m in uncharted waters here but used an AI- Claude 4 to help me get through and it did.
The problem is you have to tell VS Code where the header files are located, the .so files and also the executable needs to know at runtime.
I set up Ravbug’s sdl3_sample in my home folder so all paths start /home/david/sdl3-sample.
This is my tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang-14.0 build active file",
"command": "/usr/bin/clang-14",
"args": [
"-I/home/david/sdl3-sample/SDL/include",
"-I/home/david/sdl3-sample/SDL_image/include",
"-I/home/david/sdl3-sample/SDL_mixer/include",
"-I/home/david/sdl3-sample/SDL_ttf/include",
"-g",
"${file}","${workspaceFolder}/hr_time.c",
"-L/home/david/sdl3-sample/build",
"-Wl,-rpath,/home/david/sdl3-sample/build",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-lSDL3",
"-lSDL3_image",
"-lSDL3_ttf"
],
"options": {
"cwd": "/usr/bin"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
The lines that are SDL3 specific include the -I’s to provide the include path. -L the path to the .so files and the -rpath line is the path to the runtime files which gets linked into the executable.
If you add these three lines into c_cpp_properties.json then you’ll also avoid the dreaded red squiggles.
"includePath": [
"${workspaceFolder}/**",
"/home/david/sdl3-sample/SDL/include",
"/home/david/sdl3-sample/SDL_image/include",
"/home/david/sdl3-sample/SDL_ttf/include"
],
And your C’s #includes need the files prefixed like this :
#include <SDL3/SDL.h> #include <SDL3_image/SDL_image.h> #include <SDL3_ttf/SDL_ttf.h>
And here it is running on my Pi.


Although it says cannot open input file SDL2.lib, I think the problem is a parameter passed into Link.exe.




Well actually I asked Microsoft’s CoPilot AI and it sorted it!
This is on Ubuntu 24.04 LTS. I’ve installed the dev versions of SDL2, including images and TTF. You can read how to install them in
It’s been a few years since I compiled the code for the first eBook and I needed to create an SDL application on Windows. I copied a project, as it was the fastest way to setup the include and lib paths, and the lib files needed to compile.
A reader asked me how to setup SDL2 for Windows given recent changes in SDL2. Specifically the files and libsdl projects have been moved from the libsdl.org website to GitHub. You can easily find SDL2 Image, Mixer, TTF etc.
I had this tutorial pencilled in to do and it’s
Back in 2014, an Italian developer called Gabriele Cirulli devised a puzzle game called 2048. It has been implemented on many platforms (I have it on my iPhone) and here is