keywords: Zig, Include C++ third party, headers, libraries

Third Party Path in Application

build.zig

const Builder = @import("std").build.Builder;

pub fn build(b: *Builder) void {
    const mode = b.standardReleaseOptions();
    const exe = b.addExecutable("glfw_test", "src/main.zig");
    exe.setBuildMode(mode);

    const run_cmd = exe.run();

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);

    b.default_step.dependOn(&exe.step);
    b.installArtifact(exe);

    // glfw (local)
    exe.addIncludeDir("C:/third_party/glfw3/include/");
    exe.addLibPath("C:/third_party/glfw3/lib/");
    exe.linkSystemLibrary("glfw3");
}
Third Party Path in System

build.zig#L383-L395

self.addNativeSystemIncludeDir("/usr/local/include");
self.addNativeSystemLibPath("/usr/local/lib");

self.addNativeSystemIncludeDir(self.fmt("/usr/include/{}", triple));
self.addNativeSystemLibPath(self.fmt("/usr/lib/{}", triple));

self.addNativeSystemIncludeDir("/usr/include");
self.addNativeSystemLibPath("/usr/lib");

// example: on a 64-bit debian-based linux distro, with zlib installed from apt:
// zlib.h is in /usr/include (added above)
// libz.so.1 is in /lib/x86_64-linux-gnu (added here)
self.addNativeSystemLibPath(self.fmt("/lib/{}", triple));

build.zig#L1279

pub fn addLibPath(self: *LibExeObjStep, path: []const u8) void {
    self.lib_paths.append(path) catch unreachable;
}

Reference:
Build System: how do I configure library paths?
https://www.reddit.com/r/Zig/comments/bosqn6/build_system_how_do_i_configure_library_paths/?ref=readnext


But when a woman decides to sleep with a man, there is no wall she will not scale, no fortress she will not destroy, no moral consideration she will not ignore at its very root: there is no God worth worrying about. ― Gabriel García Márquez, Love in the Time of Cholera