Last modified date : 2025-04-30
This covers the installation of SDL3 on a Unix system based on Debian (with apt).
Contribute to cover more systems.
Below explanations are if you plan to build the whole library from sources of the official Github repository.
From the global SDL organization on Github, download the zip of these packages :
Package name | version | repository URL | description |
---|---|---|---|
Core | 3.0 | https://github.com/libsdl-org/SDL | Core required package |
SDL_image | 3.0 | https://github.com/libsdl-org/SDL_image | Used for images and textures |
SDL_ttf | 3.0 | https://github.com/libsdl-org/SDL_ttf | Used for text and fonts managment |
SDL_mixer | 3.0 | https://github.com/libsdl-org/SDL_mixer | Used for audio |
SDL_net | 2.0 | https://github.com/libsdl-org/SDL_net | Used for networking |
The process for each package will be the same.
However, some will require other packages, otherwise it won't build.
Packages that have dependencies :
Package name | dependency | guide for installation |
---|---|---|
SDL_ttf | freetype | go to chapter |
# assuming you are in ~/Download folder, with all SDL*.zip in it
# 1. setup
mkdir SDL3_setup && cd SDL3_setup
mv ../SDL*.zip .
mkdir build
# Repeat step 2 and 3 for each packages you want to install
# 2. prepare for the desired package
unzip SDL-main.zip
# optional step
rm -rf ./build/* # clean folder for next installation
# 3. build and install
cd build
cmake ../SDL-<package-name>/CMakeLists.txt -B .
make
sudo make install
Go on the official download page and click on the sourceforge link.
Download the tar.xz file.
Extract with tar -xf freetype-<version>.tar.xz
, replacing <version>
by the version you have, then move inside the extracted folder.
You can find documentation for the installation depending your system, in the
doc/
folder.
Then build the package :
sh autogen.sh
./configure # this will install in /usr/local. See --help for moving target
make
sudo make install
#include <iostream>
#include <SDL3/SDL.h>
int main(int argc, char **argv) {
if(SDL_Init(SDL_InitFlags::SDL_INIT_VIDEO) < 0) {
std::cerr << "Init error : " << SDL_GetError() << std::endl;
return EXIT_FAILURE;
}
auto window = SDL_CreateWindowWithPosition(
"MCE",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
720, 405,
SDL_WindowFlags::SDL_WINDOW_OPENGL
);
if(!window) {
std::cerr << "Window creation error : " << SDL_GetError() << std::endl;
SDL_Quit();
return EXIT_FAILURE;
}
bool isRunning = true;
while(isRunning) {
// render here
// input
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_EventType::SDL_EVENT_QUIT:
isRunning = false;
break;
}
}
}
SDL_Quit();
return EXIT_SUCCESS;
}
@kuliok1 Which file ? The minimal example code ? Like any other C++ code. With an IDE, or with clang/g++.
Also, SDL has officially released the SDL3, so now we should be able to download it directly and simply via
sudo apt-get install libsdl3-dev
.See here