foxnne / pixi

Pixel art editor made with Zig.
https://foxnne.github.io/pixi/
MIT License
738 stars 23 forks source link

Failure to compile without gtk3-dev installed #15

Closed kdchambers closed 1 year ago

kdchambers commented 1 year ago

When trying to run the project I get the following error:

/home/keith/github/pixi/src/deps/nfd-zig/nativefiledialog/src/nfd_gtk.c:1:1: error: unable to build C object: clang exited with code 1
error: nfd...
error: The following command exited with error code 1:
/home/keith/apps/zig-linux-x86_64-0.10.0/zig build-lib /home/keith/github/pixi/src/deps/nfd-zig/src/lib.zig -cflags -Wall -- /home/keith/github/pixi/src/deps/nfd-zig/nativefiledialog/src/nfd_common.c -cflags -Wall -- /home/keith/github/pixi/src/deps/nfd-zig/nativefiledialog/src/nfd_gtk.c -lc -latk-1.0 -lgdk-3 -lgtk-3 -lglib-2.0 -lgobject-2.0 --cache-dir /home/keith/github/pixi/zig-cache --global-cache-dir /home/keith/.cache/zig --name nfd -static -I /home/keith/github/pixi/src/deps/nfd-zig/nativefiledialog/src/include --enable-cache
error: the following build command failed with exit code 1:
/home/keith/github/pixi/zig-cache/o/82d56624fe6eb18572bc1eeb3f795282/build /home/keith/apps/zig-linux-x86_64-0.10.0/zig /home/keith/github/pixi /home/keith/github/pixi/zig-cache /home/keith/.cache/zig run

Maybe you can add gtk-3 requirement in README?

foxnne commented 1 year ago

Thank you for the issue! I don't currently have a Linux machine for testing so this is really helpful. I wish I could get by without the user to have to have anything outside of what zig-gamedev requires.

kdchambers commented 1 year ago

Well, I guess the solution is to add the GTK headers to https://github.com/foxnne/nfd-zig so it can build. It will still need to link to GTK at runtime but that shouldn't be an issue for most people. I can look into it this week and submit a PR if you're happy with that.

foxnne commented 1 year ago

That would be amazing but if you don't want to and think it's better to require the user to install it, I can just document it.

kdchambers commented 1 year ago

Keeping the requirement to install gtk+3-devel (Or equivalent) seems to be the best option sadly.

I wrote the necessary c definitions so that gtk.h could be removed, but it still doesn't compile because it can't find libgtk+3.so to link to. I'm not completely sure how the whole system is supposed to work, because I have libgtk+3.so.0 installed on my system, but it doesn't match due to the version suffix. If I just symlink libgtk+3.so.0 => libgtk+3.so it works fine, but that's obviously not a good solution.

I think the only thing the devel package is doing to allow it to link, is adding definitions for pkg-config to use to find the correct file.

Anyways, seems like it's doable, but probably not worth the effort.

foxnne commented 1 year ago

Understood, thanks so much for looking into this! I'll get a note added to the readme for Linux users.