On NixOS, with SDL2, SDL2_image, SDL2_ttf and curl, zig build is giving
me the following:
.../include/SDL2/SDL_image.h:27:10: note: 'SDL.h' file not found
#include "SDL.h"
^
This is a common SDL kink, which is usually worked around with
pkg-config. I am rather surprised that it worked out of box for you
on Alpine, and I do not know how to get it to work with zig build
(I faced this in another project using SDL and ended up using another
library for image loading), so I'll leave it here in case someone
knows a solution.
On Mon, Oct 4, 2021, at 10:30 AM, Nguyễn Gia Phong wrote:
> On NixOS, with SDL2, SDL2_image, SDL2_ttf and curl, zig build is giving> me the following:>> .../include/SDL2/SDL_image.h:27:10: note: 'SDL.h' file not found> #include "SDL.h"> ^>> This is a common SDL kink, which is usually worked around with> pkg-config. I am rather surprised that it worked out of box for you> on Alpine, and I do not know how to get it to work with zig build> (I faced this in another project using SDL and ended up using another> library for image loading), so I'll leave it here in case someone> knows a solution.
I wonder if this is a NixOS-specific issue or something generally we need
to worry about for builds. Like I wonder if things 'just work' on arch,
debian etc. On alpine yes no extra steps or pkg-config is needed. I
remember when I used to do dev with Nix & Zig - my workaround was to
add paths in the build.zig within `setDependencies` for each dep like:
step.addLibPath("/nix/store/wm1rx10zgkh2jdxff8rs4rvilalkrw8a-sdl/lib");
step.addIncludeDir("/nix/store/wm1rx10zgkh2jdxff8rs4rvilalkrw8a-sdl/include");
Ofcourse that's a temporary hack..
I don't think that will help, because <SDL2/SDL.h> and <SDL2/SDL_*.h>
can be found as usual, but not "SDL.h". pkg-config simply adds
-I.../include/SDL2 to cc and I suppose similar could be done
in build.zig, however I think this should be solved as part of Zig
compiler/builder implementation. Of course I'm fine with a local
patch amending the include dir in build.zig but I'll try to look
into it and see if there's a generalized solution. I still can't
understand how it can work for you on Alpine though.
After a private discussion with Devin Singh, I realized
that I was missing pkg-config and due to caching the problem persists
even in the environment with the tool. I removed zig-cache and
was able to successfully compile Mepo.