Hi! i'm quite new to such low-level languages like Zig and C, and i'm trying to get my setup working. I'am currently on MacOS
I want to use glfw lib in my project. But I also want to keep dylib directly in "dependencies" folder.
build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "gyrocube",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.addLibraryPath(b.path("dependencies"));
exe.linkSystemLibrary("glfw.3");
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
So it compiles but executable doesn't know how to find dylib which is located in dependencies folder. I keep getting this error:
dyld[7109]: Library not loaded: /opt/homebrew/opt/glfw/lib/libglfw.3.dylib
Referenced from: <51D6ECF4-DFC8-38D4-8DD0-35DB566076A9> /Users/klyotskin/Desktop/gyrocube/zig-out/bin/gyrocube
Reason: tried: '/opt/homebrew/opt/glfw/lib/libglfw.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/glfw/lib/libglfw.3.dylib' (no such file), '/opt/homebrew/opt/glfw/lib/libglfw.3.dylib' (no such file)
Is there a way to tell the build system where dylib is located?
Thank you!