How to use msvc abi on windows

hello i wanted to make a d3d11 example in zig using the new translate-c the following is the translate c part of my build.zig

    const target = b.standardTargetOptions(.{});
     if (target.result.os.tag == .windows) {
         target = b.resolveTargetQuery(.{
             .abi = .msvc,
             .os_tag = .windows,
         });
     }
    const optimize = b.standardOptimizeOption(.{});

    const cwin32 = b.addTranslateC(.{
        .root_source_file = b.path("src/c/win32.h"),
        .target = target,
        .optimize = optimize,
    });
    cwin32.linkSystemLibrary("user32", .{});
    cwin32.linkSystemLibrary("gdi32", .{});
    cwin32.linkSystemLibrary("d3d11", .{});
    cwin32.linkSystemLibrary("dxgi", .{});
    cwin32.linkSystemLibrary("d3dcompiler", .{});

when using the mingw/gnu abi if fails to find d3dcompiler lib
when using msvc abi (my prefered option) it fails with the following error
error: coff does not support linking multiple objects into one.

am i not doing something correctly or is it a current limitation of zig ?

I am guessing that mingw provides some kind of package config for d3dcompiler that is not available in msvcrt.
A possible fix might be to use the actual dll name in linkSystemLibrary
i.e. "d3dcompiler_47" or whatever the name of the dll actually is.

d3dcompiler_47 fixes the issue on the mingw/gnu abi as it’s now able to find the dll.
on msvc side however it can’t find the dll using this name.

read: Not So Direct Setup | Games for Windows and the DirectX SDK blog
see also: HLSL, FXC, and D3DCompile | Games for Windows and the DirectX SDK blog

On a windows system with the latest Windows 10 SDK installed (from Visual Studio) the files are included in C:\Program Files (x86)\Windows Kits\10

> fd d3dcompiler
Include\10.0.26100.0\um\d3dcompiler.h
Include\10.0.26100.0\um\d3dcompiler.inl
Lib\10.0.26100.0\um\arm64\d3dcompiler.lib
Lib\10.0.26100.0\um\x64\d3dcompiler.lib
Lib\10.0.26100.0\um\x86\d3dcompiler.lib
Redist\D3D\arm64\d3dcompiler_47.dll
Redist\D3D\x64\d3dcompiler_47.dll
Redist\D3D\x86\d3dcompiler_47.dll
bin\10.0.26100.0\arm64\d3dcompiler_47.dll
bin\10.0.26100.0\x64\d3dcompiler_47.dll
bin\10.0.26100.0\x86\d3dcompiler_47.dll

Note that there is a d3dcompiler.lib so your initial version was correct for msvcrt.
That means that your system is not configured to use the visual studio locations or you did not install the Windows 10(/11) SDK or the dlls are not in your PATH.

Normally zig autodetects the installation. You can verify it using:

❯ zig libc
# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=C:\Program Files (x86)\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=C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\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=C:\Program Files (x86)\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=C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\Lib\x64

# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=C:\Program Files (x86)\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=

To install the SDK from visual studio, look in individual components:

If the PATH does not include C:\Program Files (x86)\Windows Kits\10\bin you can either add it or copy the files from redist into your application folder.