Unable to link system library dbus-1 on generic linux compile

I am adding native file dialog extended as a dependency to my project, and I am using portal instead of gtk to avoid X11 conflicts with glfw.zig. When compiling to x86_64-linux (not native), I get: error: error: unable to find dynamic system library 'dbus-1' using strategy 'paths_first'. searched paths: none. I found the “searched paths: none” to be particularly odd, and I’ve verified that I have libdbus-1-dev on my machine (as well as libdbus-1-3).

I am not completely sure about how --search-prefix is meant to be used, but for me it seemed to work to use something like (to add search paths):

--search-prefix /usr

Edit: I don’t know about dbus and what to do for it specifically.

On further inspection it looks like the libdbus-1-dev package places the shared object in usr/lib/x86_64-linux-gnu instead of just usr/lib. --search-prefix usr/ only searches for objects directly in usr/lib, and other search prefixes don’t work as far as I can tell.

I encountered the same issue, solved here.

// Get the dbus include directories, for some reason not picked up by linkSystemLibrary like with libsystemd
const dbus_include_paths = std.mem.trim(u8, b.run(&.{ "pkg-config", "--cflags-only-I", "dbus-1" }), " \n");
    var iter = std.mem.splitScalar(u8, dbus_include_paths, ' ');
    while (iter.next()) |path| {
        dbus_translate_c.addSystemIncludePath(.{ .cwd_relative = path[2..path.len] });
    }

Not ideal though, perhaps another solution is available.

Adding this didn’t seem to fix my issue. I do also get: warning: add '/usr/include/dbus-1.0' to header searchlist '-isystem' conflicts with '-I'.

One thing to note is that the dependency I forked to add this change to is from zig 0.14.0 and uses addCSourceFile and addCMacro, so I used addSystemIncludePath on the root module instead of c_translate.