~mil/mepo-devel

4 3

SDL_*.h cannot find SDL.h

Details
Message ID
<CEQP0QL10ZLF.5BB34HUQXSEB@nix>
DKIM signature
pass
Download raw message
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.
Details
Message ID
<b5ab7915-a43e-4cc9-9e66-85d3684d8225@www.fastmail.com>
In-Reply-To
<CEQP0QL10ZLF.5BB34HUQXSEB@nix> (view parent)
DKIM signature
pass
Download raw message
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..
Details
Message ID
<CER9PHD77LZP.2QZ73GTRLT5RM@nix>
In-Reply-To
<b5ab7915-a43e-4cc9-9e66-85d3684d8225@www.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
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.
Details
Message ID
<CFG6XAG1I46S.22WY0NWOMUE1L@nix>
In-Reply-To
<b5ab7915-a43e-4cc9-9e66-85d3684d8225@www.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
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.
Details
Message ID
<c88af12b-1543-b9c5-f42a-65eac144a46a@disroot.org>
In-Reply-To
<b5ab7915-a43e-4cc9-9e66-85d3684d8225@www.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
Just in case, here is mepo NUR package: 
https://github.com/sikmir/nur-packages/commit/5c08af77486e2f60565b107c50a62dd1f8d424e4
Reply to thread Export thread (mbox)