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

erros when third party libraries were missing
D:\workspace\zig_dev\vulkan-zig>zig build
.\examples\c.zig:1:20: error: C import failed
pub usingnamespace @cImport({
                   ^
.\zig-cache\o\b8a39adb4a7b9e4f59c4e19b38816fd3\cimport.h:2:10: note: 'GLFW/glfw3.h' file not found
#include <GLFW/glfw3.h>
         ^
.\examples\triangle.zig:44:10: error: container 'c' has no member called 'glfwInit'
    if (c.glfwInit() != c.GLFW_TRUE) return error.GlfwInitFailed;
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