Skip to content

[zig] Compile.linkSystemLibrary2 cant find pkgconfig file #26878

@heloonihao

Description

@heloonihao

Description / Steps to reproduce the issue

const exe = b.addExecutable(.{
        .name = "abc",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
            .imports = &.{ .{ .name = "abc", .module = abc }, .{ .name = "abc", .module = abc } },
        }),
    });
    exe.linkLibC();
    // Dose not work
    exe.linkSystemLibrary2("sdl3", .{ .use_pkg_config = .force });

there is zig compiler log

$ zig build run
run
└─ run exe cardzig
   └─ install
      └─ install cardzig
         └─ compile exe cardzig Debug native failure
error: error: unable to find dynamic system library 'SDL3' using strategy 'paths_first'. searched paths: none

error: the following command exited with error code 1:
"D:\\msys64\\clang64\\bin\\zig.exe" build-exe -lSDL3 -ODebug --dep vulkan --dep renderer "-Mroot=D:\\Proj\\cardzig\\src\\main.zig" "-Mvulkan=D:\\Proj\\cardzig\\src\\vk.zig" "-Mrenderer=D:\\Proj\\cardzig\\src\\Renderer.zig" -lc --cache-dir .zig-cache --global-cache-dir "C:\\Users\\heloonihao\\AppData\\Local\\zig" --name cardzig --zig-lib-dir "D:\\msys64\\clang64\\lib\\zig\\" --listen=-

Build Summary: 0/5 steps succeeded; 1 failed
run transitive failure
└─ run exe cardzig transitive failure
   ├─ compile exe cardzig Debug native failure
   └─ install transitive failure
      └─ install cardzig transitive failure
         └─ compile exe cardzig Debug native (reused)

error: the following build command failed with exit code 1:
.zig-cache\o\b234a6a787ffc77acf6671ac497a581a\build.exe D:\msys64\clang64\bin\zig.exe D:\msys64\clang64\lib\zig D:\Proj\cardzig .zig-cache C:\Users\heloonihao\AppData\Local\zig --seed 0x1f23579b -Z5aee1554337a7cb7 run

Expected behavior

Should found pkgconfig file
andzig libcshould like this

# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=/clang64/include

# The system-specific include directory. May be the same as `include_dir`.
# On Windows it's the directory that includes `vcruntime.h`.
# On POSIX it's the directory that includes `sys/errno.h`.
sys_include_dir=/clang64/include

# The directory that contains `crt1.o` or `crt2.o`.
# On POSIX, can be found with `cc -print-file-name=crt1.o`.
# Not needed when targeting MacOS.
crt_dir=/clang64/lib

# The directory that contains `vcruntime.lib`.
# Only needed when targeting MSVC on Windows.
msvc_lib_dir=

# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=

# The directory that contains `crtbeginS.o` and `crtendS.o`
# Only needed when targeting Haiku.
gcc_dir=

Actual behavior

but it dose not find pkgconfig
```zig libc`` show

# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=D:\Windows Kits\10\Include\10.0.26100.0\ucrt

# The system-specific include directory. May be the same as `include_dir`.
# On Windows it's the directory that includes `vcruntime.h`.
# On POSIX it's the directory that includes `sys/errno.h`.
sys_include_dir=D:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\incl
ude

# The directory that contains `crt1.o` or `crt2.o`.
# On POSIX, can be found with `cc -print-file-name=crt1.o`.
# Not needed when targeting MacOS.
crt_dir=D:\Windows Kits\10\Lib\10.0.26100.0\ucrt\x64

# The directory that contains `vcruntime.lib`.
# Only needed when targeting MSVC on Windows.
msvc_lib_dir=D:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.50.35717\Lib\x64

# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=D:\Windows Kits\10\Lib\10.0.26100.0\um\x64

# The directory that contains `crtbeginS.o` and `crtendS.o`
# Only needed when targeting Haiku.
gcc_dir=

Verification

Windows Version

MINGW64_NT-10.0-19045

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANGARM64

Are you willing to submit a PR?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions