SDL3 (Simple DirectMedia Layer 3) is a cross-platform C library for building games and multimedia applications. The latest version 3 was released in 2025 and can be seen as stable now. In comparison with its predecessor SDL2, it is a major clean-up and redesign intended to make the API more consistent, with better support for modern platforms.
In 2018, I started working on my (hand-written) interface bindings to SDL2 to create 2D/3D graphics in Fortran. While not complete, the bindings cover the important parts of SDL2, SDL2_image, SDL2_mixer, and SDL2_ttf.
For SDL3, I’m aiming for a complete and auto-generated coverage of the API in Fortran 2023, called fortran-sdl3 (requires SDL ≥ 3.4). After > 37,000 SLOC it’s still far from finished, but already sufficiently completed for creating small games or graphics demos (some are provided in the repo). I’ve tested the bindings on FreeBSD 15 and Debian 13. Windows and macOS should be supported, too (albeit with different linker libraries).
Useful is an understatement. Thanks for keeping up the great work you do, creating bindings for multimedia libraries (in addition to your other great projects). I plan to re-implement and migrate some older projects to SDL3, so your work here will come in more than handy!
SDL is a great library, it shows how to create an API. Simple, easy to use from any language, complete and stable. SDL3 is their third iteration in almost 30 years (extremely impressive!). When I am designing a new API, I often consult how SDL does it and learn from them.
I have used SDL3 GPU API, and it’s amazing. GPU APIs are notoriously complex (Vulkan, DirectX, etc.), and the SDL3 GPU API is simple, yet completely usable.
I don’t know the authors at all, but they have done an A+ job.
SDL3 3.4.14 is too old. The function is not in any release version yet. I’ve had taken the header files from the SDL3 main branch. But you can just comment out the interface for now.
After comment out function sdl_show_notification_() & function sdl_show_notification(), I get libfortran-sdl3.dll and a few exes for the examples, like bship.exe. It works.
For forest.f90, there are multiple definition errors of `_gfortran_set_options’, `_gfortran_os_error_at’, …
It seems libgfortran.a has it. libfortran-sdl3.dll.a also has it. Maybe libfortran-sdl3 doesn’t need to define it? Just use gfortran’s?
[ 32%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3.F90.obj
[ 34%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_image.F90.obj
[ 35%] Building C object CMakeFiles/fortran-sdl3.dir/src/sdl3_macro.c.obj
[ 37%] Linking Fortran shared library libfortran-sdl3.dll
[ 59%] Built target fortran-sdl3
[ 60%] Building Fortran object CMakeFiles/affine.dir/examples/affine.f90.obj
[ 62%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/affine.exe
[ 62%] Built target affine
[ 64%] Building Fortran object CMakeFiles/bship.dir/examples/bship.f90.obj
[ 65%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/bship.exe
[ 65%] Built target bship
[ 67%] Building Fortran object CMakeFiles/clear.dir/examples/clear.f90.obj
[ 68%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/clear.exe
[ 68%] Built target clear
[ 70%] Building Fortran object CMakeFiles/dvd.dir/examples/dvd.f90.obj
[ 71%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/dvd.exe
[ 71%] Built target dvd
[ 73%] Building Fortran object CMakeFiles/forest.dir/examples/forest.f90.obj
[ 75%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/forest.exe
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../lib/libgfortran.a(compile_options.o): in function `_gfortran_set_options':
/home/gfortran/gcc-home/workshop/gcc/objdir64/x86_64-w64-mingw32/libgfortran/../../../gcc-12.1.0/libgfortran/runtime/compile_options.c:147: multiple definition of `_gfortran_set_options'; D:/00master/sdl3/fortran-sdl3-master/lib/libfortran-sdl3.dll.a(d000407.o):(.text+0x0): first defined here
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../lib/libgfortran.a(error.o): in function `_gfortran_os_error_at':
/home/gfortran/gcc-home/workshop/gcc/objdir64/x86_64-w64-mingw32/libgfortran/../../../gcc-12.1.0/libgfortran/runtime/error.c:384: multiple definition of `_gfortran_os_error_at'; D:/00master/sdl3/fortran-sdl3-master/lib/libfortran-sdl3.dll.a(d000399.o):(.text+0x0): first defined here