What should my next steps be to switch to building them using Zig? (I want to be able to cross-compile for Windows, currently it’s failing with the error below)
error: error: unable to find dynamic system library 'SDL2' using strategy 'paths_first'. searched paths: none
error: unable to find dynamic system library 'SDL2_mixer' using strategy 'paths_first'. searched paths: none
error: unable to find dynamic system library 'GL' using strategy 'paths_first'. searched paths: none
Are you switching from building natively for your own (Linux? Mac?) machine to cross-compiling for Windows? Did you install the SDL/libGL with a package manager?
searched paths: none indicates that Zig didn’t look for the library anywhere.
When cross-compiling, Zig won’t look in your system for installed libraries, because the libraries on your machine probably won’t work on the machine you’re compiling for.
Instead you need to get a copy of the library for Windows and then specify the location of the library file. There’s a few different ways to do that depending on what you need, but the simplest is probably with std.Build.addLibraryPath pointing to a folder with the libraries.
Unfortunately this package relies on system libraries so you won’t be able to use it to cross compile your application.
(unless there is some way to do the build without the system libraries or supply the needed parts, I am not entirely sure, for pure dynamic libraries it may work, but if there are also headers needed at build time it would probably fail)
I haven’t used this package in particular, but usually you start with adding it as a dependency to your project with:
SDL_opengles.h:33:10: error: 'GLES/gl.h' file not found
So maybe it relies on system headers for that.
I just saw that the build.zig uses linkSystemLibrary for window / mac etc., so that won’t work may not unless you compile on windows. (not sure)
I think (but I am not sure that) if you want cross compile to work you would have do a lot of work on the SDL2 library to make it support cross compile (remove/bundle all the system dependencies), would probably be way easier to get different compiled libraries like @tsdtas has suggested.
Alternatively you could port your application to use SDL3 and this project:
Compile, check missing symbols, google which windows lib it’s in and link it.
You can search the zig repo for the windows functions you need and check the library name also.
It also works for macOS system libs. For Linux x11 and wayland headers you can use Hexops · GitHub repos and use fetch them with build.zig.zon if SDL depends on them.