I wanna make a little application that has a gui, honestly more of a script for people who are scared of typing.
Attempt Nr. 1
I tried to use capy-ui, but it says I have to use a nominated mach version, which I dont want to, but am willing to if nothing else works. It’s build script is also really weird, which is why I would like to avoid it.
Attempt Nr. 2
The only other alternative I could find was imgui, the issue is, I want a static binary and I dont know how to link a cpp lib statically.
ocornut/imgui has a bindings page that includes Zig. In theory those bindings for Zig should provide you with working examples. I haven’t personally tried any of those but I recognized michal-z and SpexGuy in there and they probably have good quality code in their respective repos.
That said…
Importing the build script of a dependency and using funcionality exposed by it is 100% legitimate and by design (the ability to import build scripts was added to the build system specifically to enable this use case).
You can go read the implementation of capy.runStep in the build script in there and you can even copy-paste its implementation directly in your build.zig, if you don’t like things happening without your direct control.
Alright Im back to the capy plan. I managed to get the build file to (mostly) compile by using 0.13.0 and snippets from the capy example project.
My issue now is that capy cant find the .a and .so files.
The error is:
error: error: unable to find dynamic system library 'gtk4' using strategy 'paths_first'. searched paths:
/usr/local/lib64/libgtk4.so
/usr/local/lib64/libgtk4.a
/usr/local/lib/libgtk4.so
/usr/local/lib/libgtk4.a
/usr/lib/x86_64-linux-gnu/libgtk4.so
/usr/lib/x86_64-linux-gnu/libgtk4.a
/lib64/libgtk4.so
/lib64/libgtk4.a
/lib/libgtk4.so
/lib/libgtk4.a
/usr/lib64/libgtk4.so
/usr/lib64/libgtk4.a
/usr/lib/libgtk4.so
/usr/lib/libgtk4.a
/lib/x86_64-linux-gnu/libgtk4.so
/lib/x86_64-linux-gnu/libgtk4.a
I am on voidlinux x86_64 glibc.
Is there a chance that naming conventions for libraries are just different on void to whatever the capy devs use or am I missing a package?
On second thought, zig have pkg-config integration. So normally “gtk4” must work.
Try pkg-config --libs gtk4
If gtk4 is not found, try to install a development package for gtk4.
If gtk4 is found by pkg-config, build.zig must work.
I just ran zig build run and it actually compiled, but crashed at runtime
=> zig build run
warning: 'many-counters' is broken (disabled by default)
Segmentation fault at address 0x0
???:?:?: 0x7fc2462c8eed in ??? (libgtk-4.so.1)
Unwind information for `libgtk-4.so.1:0x7fc2462c8eed` was not available, trace may be incomplete
Lmao I just got capy working, but yea I remember that that also exists.
How does it compare to capy? It does look quite nice.
Also how easy is it to import? Is it just zig fetch and go?
And my biggest question: Does it depend on other ui toolkits or is it just based on a raw canvas (sdl opengl etc), can I statically link it and is it pure zig?
All those points you listed are ones I really appreciate.
I have been reading the example a bit and adapting the code style more to mine. So far I can say that the api does feel a bit raw (like the variable framerate time tracking, how you have to attack frontend to backend), but I really really like it.