How do I specify the location of my personal utilities files on system-wide
I have a collection of various utility functions that I use across
a variety of different (independent) programs.
To keep a flat directory structure (easier for navigation/overview),
I avoid the “zig init-exe” step, since it creates the cumbersome build.zig,
src/, and zig-out/ subdirectories.
The preference is just to use “zig build-exe myfile.zig” when developing
and experiment with it by typing “myfile”. Pretty simple.
Suppose I keep all of my personal utilities in separate files in a directory “~/ZigUtils”.
Without needing a separate “build.zig” file for every program that I
develop, How I do tell my program under develop to find the
I have tried using the lines in my main.zig file:
"const util_x = @import("~/ZigUtils/util_x.zig" "const util_x = @import("../../ZigUtils/util_x.zig"
But always get the dreaded “error: import of file outside package path”.
Probably I need to add “~/ZigUtils” to my package path. How do I do this
on a system-wide basis? (so I do not need separate build.zig files for each
There is likely some editing of the “/usr/local/zig/build.zig” to be done.
But, I do not see the solution.
Thanks for all hints here.
PS I have read Felix “xq” Qusissner’s excellent series on “zig build explained”
where he details including the build process, and how to deal with “c” libraries,
etc. But, I couldn’t figure out how to develop and maintain my own “zig native”
personal utility library. (This is the real, underlying question for me.)