Tag Archives: linux

Linux Tutorial News Cover Image

How to Compile and Install SDL3 in Linux?

The bad news is that in many popular Linux distributions there are no pre-compiled SDL3 library files as of now (28/10/2025) available to be easily installed on the system.

The good news is, this description will show you how to compile them easily and quick yourself.

Step 1: Download and Extract the Libraries

Obviously we need the source code of the respective library. Usually these are:

  • SDL3 for the core system
  • SDL3_image for convenient image functions
  • SDL3_ttf for easy usage of fonts
  • SDL3_mixer for convenient sound and music functions

Other libraries may have differing procedures.

  • Go to the linked release page.
  • Go to the latest release with a preceding 3 in the version number (3.x.x)
  • at the bottom of the release there is a drop-down button called “Assets”, click on it
  • the last two entries contain the source code of the chosen release, click on the zip-entry to download it

For SDL3_mixer there is no official release available as of now (28/10/2025).

In the future there will be a release of SDL3_mixer, too. You may then also get it from the release page.

Extract all libraries to their respective folders.

Step 2: Compiling (Building) the Libraries using CMake

For all aforementioned libraries (SDL3, SDL3_image, SDL3_ttf, SDL3_mixer) the same procedure is applicable.

  • open the terminal (console, shell)
  • go to the respective main folder of the extracted file, e. g. SDL3-3.2.0 if you downloaded and extracted version 3.2.0 of the SDL3 source code
  • now run these three commands one after another:
cmake -S . -B build
cmake --build build
sudo cmake --install build --prefix /usr/local

cmake is a software building tool usually already installed on your Linux system or easily available via your system’s package manager (see bottom of page to see how). What these lines do:

Line 1: Configure the source directory (-S) to be the current directory (.) and the destination directory (-B) for the results of the build procedure (build).

Line 2: Do the actual building (–build) and put the result in the build directory. This step may take some time.

Line 3: Install the built results in directory build (–install build) to the /usr/local directory. This will create a sub-folder “lib” in which the successfully compiled dynamic libraries will reside (.so files). Consequently the full path to them is /usr/local/lib.

The folder /usr/local is used typically to store programs that are not managed by Linux’ package manager. As we did not install the libraries via the package manager, we consequently choose this folder to store the results. If in the future SDL3 will be available in the package manager, we can simply delete the folder’s content related to SDL3.

Step 3: Make SDL3 known to your System

In Windows it is sufficient to copy the libraries to specific folders to make them known system-wide. Specifically in Linux, you have to make sure your system adds them to an internal library cache additionally.

Step 1: Verifying Library folder

First let’s verify that the folder /usr/local/lib is known as library folder. Type this in the terminal.

cd /etc/ld.so.conf.d
cat libc.conf

The first line changes into the ld.so.conf.d system folder. The second line prints the content of the file libc.conf to the terminal. If this shows you a list containing /usr/local/lib then the folder is known and everything is alright.

Otherwise, but if a libc.conf file still exists, just add the folder /usr/local/lib to it and save. If not even the libc.conf file exists, please check where the library folders are found for your Linux distribution.

Step 2: Updating Cache and check if Library is known

sudo ldconfig
ldconfig -p

The first line updates the cache. Not much appears on the terminal.

The second line prints out a long list of libraries. Scroll up to libSDL3. There you should see all libraries you just added to the cache like this:

Now you are finished and ready to use SDL3 in Linux.

Have fun. 🙂

CMake is not installed on your System

If you are unsure, try the following lines. The first lines returns the version of cmake, if it is installed on your system. Skip the other lines in this case. If the first line returns an error message, install cmake by the other two commands.

cmake --version
sudo apt update
sudo apt install cmake

Now you should be able to install SDL3 with the steps shown above.

SDL3 Install Chapter Feature Image

Installation of SDL3 (Linux and Windows)


Step 1: Get the SDL3 Library to your system

Step 2: Install SDL3

Windows

For Windows it is as easy as copying the SDL3.dll to your system or system32 folder (try it out). Alternatively you can also just copy the SDL3.dll in the same folder as your SDL3 application resides.

Linux

As SDL3 is very new, it has not been entered the package managers of the Linux distributions yet. This means, you need to compile and install it manually.

For a detailed description on how to compile or build and install SDL3 under Linux, please check this out: How to Compile and Install SDL3 in Linux.

Step 3: Get the SDL3 unit for Pascal

Step 4: Setup Lazarus Project

If you use the Lazarus IDE for development, do not forget to set the following paths:

In the “Paths” sub-options menu of the “Compiler Options”, you need to set the path in “Other unit files (-Fu)” to the SDL3 units. The setting (“units”) as displayed in the screenshot means that the SDL3 unit files are in a “units” subfolder of your application folder.

For other editors you need to set them accordingly. If you compile from command line, use the compiler flags.

If your SDL3 shared library files are not recognized system wide you may have copied the DLL files to the wrong system folder on Windows. In Linux the way to achieve this is described in the mentioned article.

That’s it, you should be able to run SDL3 applications done in Pascal now. 🙂

Next Chapter