Duplicate symbol linking libc

I was developing a thing on linux, and wanted to try it on windows. I’m using raylib and libc so I linked them this way. I have the static binaries pre-built.

    exe.linkLibC();

    exe.addIncludePath(.{ .path = "thirdparty/include/" });

    if (target.result.os.tag == .windows) {
        exe.addLibraryPath(.{ .path = "thirdparty/lib/windows" });
    } else if (target.result.os.tag == .linux) {
        exe.addLibraryPath(.{ .path = "thirdparty/lib/linux" });
    }
    exe.linkSystemLibrary("raylib");

but when building I get this error. I’ve ran out of ideas.

error: lld-link: duplicate symbol: __guard_check_icall_fptr
    note: defined at mingw32.lib(mingw_cfguard_support.obj)
    note: defined at MSVCRT.lib(guard_support.obj)
error: lld-link: duplicate symbol: __guard_dispatch_icall_fptr
    note: defined at mingw32.lib(mingw_cfguard_support.obj)
    note: defined at MSVCRT.lib(guard_support.obj)

Thanks in advance for your time and help.

There are two targets abi for windows the -windows-gnu (mingw runtime) and the -windows-msvc (Microsoft visual c runtime).
It seems that raylib is linked with one abi and you are building using the other one.
Try building with zig build -Dtarget=native-windows-gnu
or zig build -Dtarget=native-windows-msvc.

1 Like