# SDL (noob)

**URL:** <https://ziggit.dev/t/sdl-noob/17759>\
**Category:** Help\
**Tags:** language\
**Created:** [September 30, 2026, 1:58pm UTC](https://ziggit.dev/t/sdl-noob/17759 "2026-09-30T13:58:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [September 30, 2026, 1:58pm UTC](https://ziggit.dev/t/sdl-noob/17759/1 "2026-09-30T13:58:52Z")

</div>

I decided I have to do some SDL stuff, instead of digging into the windows API.  
This is step zero for me… Never did anything with the plethora of graphics / sound etc. possibilities.  
What I do _not_ want is a `build.zig` of 2000 lines with SDL stuff.

So the (for me) cleanest and easiest way is maybe what I saw here:  
[here](https://www.youtube.com/watch?v=dLh5svxKs_0)  
(The code on github in the description of the video).

The only riddle I stumbled upon was this:

```zig
pub const c = @cImport({
    @cInclude("SDL3/SDL.h");
});

```

Where or where is the location of this? What is the magic behind it?

---

<div class="post-metadata">

**Author:** ![pasta](https://ziggit.dev/user_avatar/ziggit.dev/pasta/32/6273_2.png) [@pasta](https://ziggit.dev/u/pasta)\
**Post date:** [September 30, 2026, 2:04pm UTC](https://ziggit.dev/t/sdl-noob/17759/2 "2026-09-30T14:04:18Z")

</div>

The magic behind it is that it has been [deprecated in 0.16.0](https://ziglang.org/download/0.16.0/release-notes.html#cImport-Moving-to-Build-System). That link should explain the details and alternatives.

edit: also note that in 0.17.0 translate-c has entirely moved out so must be pulled in as a dependency.

---

<div class="post-metadata">

**Author:** ![Southporter](https://ziggit.dev/user_avatar/ziggit.dev/southporter/32/2500_2.png) [@Southporter](https://ziggit.dev/u/Southporter)\
**Post date:** [September 30, 2026, 2:17pm UTC](https://ziggit.dev/t/sdl-noob/17759/3 "2026-09-30T14:17:18Z")

</div>

The magic behind it is the same as C include: The zig compiler will search in the include paths for the header. If these are headers are installed in known locations, it will find them and link them up.

Like @pasta said, it is going away. So you will have to use translate-c in the future. And that will remove some of the magic.

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [September 30, 2026, 2:53pm UTC](https://ziggit.dev/t/sdl-noob/17759/4 "2026-09-30T14:53:42Z")

</div>

Thx! Struggling on from here 🙂

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [October 1, 2026, 2:16pm UTC](https://ziggit.dev/t/sdl-noob/17759/5 "2026-10-01T14:16:33Z")

</div>

Got the basics working! Now for a real game 🙂

---

<div class="post-metadata">

**Author:** ![felixrabe](https://ziggit.dev/user_avatar/ziggit.dev/felixrabe/32/5355_2.png) [@felixrabe](https://ziggit.dev/u/felixrabe)\
**Post date:** [October 1, 2026, 3:17pm UTC](https://ziggit.dev/t/sdl-noob/17759/6 "2026-10-01T15:17:08Z")

</div>

> [@ericlang](#):
>
> 2000 lines with SDL stuff

I dabbled a bit with SDL3 and Zig last year, and looking at [GitHub - allyourcodebase/SDL: SDL ported to the Zig build system. · GitHub](https://github.com/allyourcodebase/SDL), the required `build.zig` stuff does not look to be 2000 lines at all. What did you mean by that?

(Btw - following along Handmade Hero using the win32 API from Linux is [not too bad either](https://ziggit.dev/t/zig-cc-g-is-ignoring-me/17768). I burned myself out at an earlier attempt trying to follow along using a different API and language.)

---

<div class="post-metadata">

**Author:** ![ericlang](https://ziggit.dev/user_avatar/ziggit.dev/ericlang/32/8515_2.png) [@ericlang](https://ziggit.dev/u/ericlang)\
**Post date:** [October 1, 2026, 3:29pm UTC](https://ziggit.dev/t/sdl-noob/17759/7 "2026-10-01T15:29:55Z")

</div>

I saw `build.zig`’s hanging around here and there that were very big (filled with SDL stuff).

Now I have - with the help of some A.I. - a build.zig which is small.

```zig
    const translate_sdl = b.addTranslateC(.{
        .root_source_file = b.path("sdl/include/SDL3/SDL.h"),
        .target = target,
        .optimize = optimize,
    });
    translate_sdl.addIncludePath(b.path("sdl/include"));

    // exe stuff here...

    exe.root_module.addImport("sdl", translate_sdl.createModule());
    exe.root_module.addIncludePath(b.path("sdl/include"));
    exe.root_module.addLibraryPath(b.path("sdl/lib/x64"));
    exe.root_module.linkSystemLibrary("SDL3", .{});

    // put SDL3.dll next to lemmix.exe
    b.getInstallStep().dependOn(
        &b.addInstallBinFile(b.path("sdl/lib/x64/SDL3.dll"), "SDL3.dll").step,
    );

    // some more stuff here...

```

I only do not have the zig functions at my disposal.  
Magically only this sdl module.

Also with some non-human help I executed:  
`zig translate-c -lc -I sdl\include sdl\include\SDL3\SDL.h > src\sdl.zig`  
and got a 50.000 lines file which seemed to represent the complete DLL.

Not understanding everything (at all) but with that youtube tutorial I am at least able to have a window and animations running around calling some of the functions inside there.  
Remember: sdl noob… 🙂

---

<div class="post-metadata">

**Author:** ![eag](https://ziggit.dev/letter_avatar_proxy/v4/letter/e/ba8739/32.png) [@eag](https://ziggit.dev/u/eag)\
**Post date:** [October 1, 2026, 8:58pm UTC](https://ziggit.dev/t/sdl-noob/17759/8 "2026-10-01T20:58:25Z")

</div>

[GitHub - tiawl/glfw.zig: @glfw packaged for @ziglang · GitHub](https://github.com/tiawl/glfw.zig) ?
