Hello 👋🏽
I have possibly a silly question, but I can't seem to find a response through google...
First time zig user, long time programmer. I am trying to link a hello world with ffmpeg to validate Zig for a work project, but I seem to be having issues doing so? I can verify I can find the compiled libs using pkg-config, but Zig does not seem to be able to do so.
Here is my 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 = "ffmpeg-demo",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
exe.linkLibC();
const ffmpegLinkOpts = std.Build.Module.LinkSystemLibraryOptions{
.needed = true,
.use_pkg_config = .yes
};
exe.linkSystemLibrary2("avformat", ffmpegLinkOpts);
exe.linkSystemLibrary2("avcodec", ffmpegLinkOpts);
exe.linkSystemLibrary2("avutil", ffmpegLinkOpts);
b.installArtifact(exe);
}
I get the following error for all three imports:
error: error: unable to find dynamic system library 'avformat' using strategy 'paths_first'. searched paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/lib/libavformat.tbd
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/lib/libavformat.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/lib/libavformat.so
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/lib/libavformat.a
Seems like it is in fact not using pkg-config to find the dependencies as I would expect, what am I doing wrong?
Thank you!!