Hello, everyone!
I’ve been away from Zig for a long time, now trying to get back to working on my pet projects using Zig ![]()
Basically, I’d like to be able to compile my pre-0.16 projects.
My little projects contain some C code, including headers. Also I link against system libraries (glfw, GL, X11, etc.).
In the old times, there was this function addIncludePath, I used it to add paths to where the C headers I use in my projects were. In build.zig, I was doing this:
const exe = b.addExecutable( … );
exe.addIncludePath(std.Build.LazyPath { .cwd_relative = “glad/include” });
How do achieve the same in Zig 0.16 or later?
Also, how do I link system libraries?
(from my pre-0.16 build.zig) :
const c_flags: []const []const u8 = &[_][]const u8{"-O2", "-ffunction-sections", "-fdata-sections"};
exe.addCSourceFile(std.Build.Module.CSourceFile { .file = .{ .cwd_relative = "glad/src/glad.c" }, .flags = c_flags });
exe.linkSystemLibrary("glfw");
exe.linkSystemLibrary("GL");
. . .
exe.linkLibC();
Currently I’m struggling with addIncludePath part, I haven’t gotten to addCSourceFile, linkSystemLibrary, and linkLibC.
It looks like addCSourceFile is now in exe.root_module:exe.root_module.addCSourceFile , but I’m not sure about linkSystemLibrary and linkLibC.