Skip to content

Instantly share code, notes, and snippets.

@NoxFly
Last active September 4, 2025 05:50
Show Gist options
  • Save NoxFly/1067c9fc24024d26b51a6825de5cff74 to your computer and use it in GitHub Desktop.
Save NoxFly/1067c9fc24024d26b51a6825de5cff74 to your computer and use it in GitHub Desktop.
SDL3 installation guide

SDL3 installation guide

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.

Download and installation

Step 1 : Download

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

Step 2 : installation process

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

Dependencies installation guide

Freetype

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

Minimal Code Example

#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;
}
@RolandHughes
Copy link

I haven't built yet, but getting through the configure script on MX Linux with most things actually being found, this is what I installed. One or more of these may not actually be needed as I had to install dependencies for my next level up library BasisDoctrina. (Nowhere near fully started yet but you can read about it here.)

apt-get install build-essential g++ fakeroot hashdeep dpkg-dev cmake \
        ninja-build git astyle hunspell
apt-get install libcups2-dev libglibmm-2.4-dev libglibmm-2.4-doc \
        zlib1g zlib1g-dev libsqlite3-dev
apt-get install libpipewire-0.3-dev libwayland-dev  libdecor-0-dev
apt-get install libasound2-dev libjack-jackd2-dev sndiod libpulse-dev \
     libdrm-dev libgbm-dev libxkbcommon-dev libegl-dev libunwind-dev \
     libusb-dev libusb-1.0-0-dev libgusb-dev

I don't know if this is everything yet, but it will let you get through the configure part of the script

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