# Fortran 2023 interface bindings to SDL3

**URL:** <https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060>\
**Category:** Announcements\
**Created:** [August 21, 2026, 12:25pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060 "2026-08-21T12:25:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [August 21, 2026, 12:25pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/1 "2026-08-21T12:25:25Z")

</div>

Greetings,

[SDL3](https://wiki.libsdl.org/SDL3/FrontPage) (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](https://github.com/interkosmos/fortran-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**](https://github.com/interkosmos/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).

Maybe, some of you find it useful.

> **Screen Shots**
>
> ![Affine transformation](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/7/7d629e13a577fafda11c013e2f296b671470ee55.jpeg)
> 
> ![Burning Ship fractal](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/c/c4c7befaf2e7a9bcd87ee676f5a1e30266a1c5ae.png)
> 
> ![OpenGL rendering of Empire State Building](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/e/ee16003f03b8e44b859284ca27d3c10250fa4e54.png)
> 
> ![Chaotic attractor](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/6/6558a6ffb98ea7fcf437ee1111b7b6daa796462f.jpeg)

---

<div class="post-metadata">

**Author:** ![fxm](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fxm/32/5726_2.png) [@fxm](https://fortran-lang.discourse.group/u/fxm)\
**Post date:** [August 21, 2026, 5:14pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/2 "2026-08-21T17:14:23Z")

</div>

> [@interkosmos](#):
>
> Maybe, some of you find it useful.

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!

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [August 22, 2026, 6:45am UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/3 "2026-08-22T06:45:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 23, 2026, 12:37pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/4 "2026-08-23T12:37:23Z")

</div>

Under Win 10 with gfortran, I built libfortran-sdl3.a and examples\affine.exe. When run, it asks for libfortran-sdl3.dll

When try to build libfortran-sdl3.dll, I linked to SDL3 and SDL3\_image, but got undefined reference to some SDL\_Log\_\*

Where is these log functions? Could you suggest what is missing?

I have installed these:  
SDL3-devel-3.4.14-mingw  
SDL3\_image-devel-3.4.4-mingw

Thanks for help.

```auto
[52%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_timer.F90.obj
[53%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_version.F90.obj
[55%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3.F90.obj
[57%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_image.F90.obj
[58%] Linking Fortran shared library libfortran-sdl3.dll
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0xb3): undefined reference to `SDL_Log_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x18e): undefined reference to `SDL_LogWarn_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x269): undefined reference to `SDL_LogVerbose_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x344): undefined reference to `SDL_LogTrace_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x429): undefined reference to `SDL_LogMessage_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x504): undefined reference to `SDL_LogInfo_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x5df): undefined reference to `SDL_LogError_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x6ba): undefined reference to `SDL_LogDebug_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_log.F90.obj):sdl3_log.F90:(.text+0x795): undefined reference to `SDL_LogCritical_'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_notification.F90.obj):sdl3_notification.F90:(.text+0x416): undefined reference to `SDL_ShowNotification'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_notification.F90.obj):sdl3_notification.F90:(.text+0x601): undefined reference to `SDL_ShowNotification'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_opengl.F90.obj):sdl3_opengl.F9:(.text+0x30): undefined reference to `glGetString'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/fortran-sdl3.dir/build.make:663: libfortran-sdl3.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:126: CMakeFiles/fortran-sdl3.dir/all] Error 2
make: *** [makefile:91: all] Error 2

D:\00master\sdl3\fortran-sdl3-master\build_win10>

```

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [August 23, 2026, 1:13pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/5 "2026-08-23T13:13:13Z")

</div>

The `SDL_Log_*` procedures are wrappers in `src/sdl3_macro.c`.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 23, 2026, 1:14pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/6 "2026-08-23T13:14:42Z")

</div>

Oh ic. I only treated the f90 file.

After adding it, only SDL\_ShowNotification not found.

I should get glGetString from open gl. Haven’t linked to it.

```auto
[54%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3.F90.obj
[56%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_image.F90.obj
[57%] Building C object CMakeFiles/fortran-sdl3.dir/src/sdl3_macro.c.obj
[59%] Linking Fortran shared library libfortran-sdl3.dll
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_notification.F90.obj):sdl3_notification.F90:(.text+0x416): undefined reference to `SDL_ShowNotification'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_notification.F90.obj):sdl3_notification.F90:(.text+0x601): undefined reference to `SDL_ShowNotification'
d:/gcc/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles/fortran-sdl3.dir/objects.a(sdl3_opengl.F90.obj):sdl3_opengl.F9:(.text+0x30): undefined reference to `glGetString'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/fortran-sdl3.dir/build.make:680: libfortran-sdl3.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:126: CMakeFiles/fortran-sdl3.dir/all] Error 2
make: *** [makefile:91: all] Error 2

```

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [August 23, 2026, 2:53pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/7 "2026-08-23T14:53:23Z")

</div>

> [@Cean](#):
>
> After adding it, only SDL\_ShowNotification not found.

Your SDL3 version is probably too old (requires ≥ SDL 3.6.0).

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 24, 2026, 2:25am UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/8 "2026-08-24T02:25:48Z")

</div>

The lastest is 3.4.14

In sdl3\_notification.F90, there are:

```auto
    function sdl_show_notification_(title, message, image, actions, num_actions) bind(c, name='SDL_ShowNotification')

```

```auto
function sdl_show_notification(title, message, image, actions, num_actions) result(id)

```

My error is: undefined reference to `SDL\_ShowNotification’

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [August 24, 2026, 3:47pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/9 "2026-08-24T15:47:38Z")

</div>

~~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.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 25, 2026, 12:28am UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/10 "2026-08-25T00:28:47Z")

</div>

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?

```auto
[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

```

 ![bship](https://global.discourse-cdn.com/free1/uploads/fortran_lang/original/2X/8/8628b3fe39b5768823a45712b24b9d0d7eaf8284.jpeg)

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 25, 2026, 12:48am UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/11 "2026-08-25T00:48:49Z")

</div>

forest.f90, palette.f90, version.f90 and window.f90 have errors when compiling.

```auto
[64%] Building Fortran object CMakeFiles/fortran-sdl3.dir/src/sdl3_image.F90.obj
[66%] Building C object CMakeFiles/fortran-sdl3.dir/src/sdl3_macro.c.obj
[67%] Linking Fortran shared library libfortran-sdl3.dll
[67%] Built target fortran-sdl3
[69%] Building Fortran object CMakeFiles/affine.dir/examples/affine.f90.obj
[71%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/affine.exe
[71%] Built target affine
[73%] Building Fortran object CMakeFiles/bship.dir/examples/bship.f90.obj
[75%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/bship.exe
[75%] Built target bship
[76%] Building Fortran object CMakeFiles/clear.dir/examples/clear.f90.obj
[78%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/clear.exe
[78%] Built target clear
[80%] Building Fortran object CMakeFiles/dvd.dir/examples/dvd.f90.obj
[82%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/dvd.exe
[82%] Built target dvd
[83%] Building Fortran object CMakeFiles/gl3core.dir/examples/gl3core.f90.obj
[85%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/gl3core.exe
[85%] Built target gl3core
[87%] Building Fortran object CMakeFiles/glempire.dir/examples/glempire.f90.obj
[89%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/glempire.exe
[89%] Built target glempire
[91%] Building Fortran object CMakeFiles/glvertex.dir/examples/glvertex.f90.obj
[92%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/glvertex.exe
[92%] Built target glvertex
[94%] Building Fortran object CMakeFiles/root3.dir/examples/root3.f90.obj
[96%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/root3.exe
[96%] Built target root3
[98%] Building Fortran object CMakeFiles/smoke.dir/examples/smoke.f90.obj
[100%] Linking Fortran executable D:/00master/sdl3/fortran-sdl3-master/bin/smoke.exe
[100%] Built target smoke

```

---

<div class="post-metadata">

**Author:** ![interkosmos](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/interkosmos/32/296_2.png) [@interkosmos](https://fortran-lang.discourse.group/u/interkosmos)\
**Post date:** [August 25, 2026, 3:07pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/12 "2026-08-25T15:07:03Z")

</div>

Does it compile using the provided `Makefile` or `fpm.toml`?

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [August 25, 2026, 10:22pm UTC](https://fortran-lang.discourse.group/t/fortran-2023-interface-bindings-to-sdl3/11060/13 "2026-08-25T22:22:24Z")

</div>

I wrote a cmakelists.txt to use cmake.
