Trouble cross compiling to windows from wsl

Howdy! I’m trying to build a gameboy emulator using zig - for the UI/Window framework I’m using zig-gamedev monorepo with zgui. I’m on zig version 0.13.0 and had no problems compiling on linux and running the binary with no issue.

However, when I tried to test things on windows, I decided to try the crosscompilation using zig build -Dtarget=x86_64-windows-gnu

This failed with the following errors:

lld-link: error: unknown file type: /home/hamada/code/erato/gb/.zig-cache/o/95774c80e658bfd479a7d4d8e68ae103/dawn.o
lld-link: error: unknown file type: /home/hamada/code/erato/gb/.zig-cache/o/91bfabc12e8f42c7ecf204be7ea526a0/dawn_proc.o

The command that generates this looks like:

zig lld-link -ERRORLIMIT:0 -NOLOGO -DEBUG \
 -PDB:/home/hamada/code/erato/gb/.zig-cache/o/e8fc1b6c8d0643823e77b2de4a9ff26a/erato-gb.pdb \
 -PDBALTPATH:erato-gb.pdb -STACK:16777216 -BASE:4194304 \
 -MACHINE:X64 -INCLUDE:_tls_index -OUT:/home/hamada/code/erato/gb/.zig-cache/o/e8fc1b6c8d0643823e77b2de4a9ff26a/erato-gb.exe \
 -IMPLIB:/home/hamada/code/erato/gb/.zig-cache/o/e8fc1b6c8d0643823e77b2de4a9ff26a/erato-gb.lib \
 -LIBPATH:/home/hamada/code/erato/gb/extern/system-sdk/windows/lib/x86_64-windows-gnu \
 -LIBPATH:/home/hamada/.cache/zig/p/1220f9448cde02ef3cd51bde2e0850d4489daa0541571d748154e89c6eb46c76a267 \
 -LIBPATH:/home/hamada/code/erato/gb/extern/system-sdk/windows/lib/x86_64-windows-gnu \
 /home/hamada/code/erato/gb/.zig-cache/o/dbd86a6d2987292b8c20793a61e93075/glfw.lib \
 /home/hamada/code/erato/gb/.zig-cache/o/4b5c9928c9ef76590acdf7177124b222/imgui.lib /home/hamada/code/erato/gb/.zig-cache/o/b8ede1f1d6849d74fcd8b0651a87aeae/libzdawn.a \
 /home/hamada/.cache/zig/p/1220f9448cde02ef3cd51bde2e0850d4489daa0541571d748154e89c6eb46c76a267/dawn.lib /home/hamada/code/erato/gb/.zig-cache/o/e8fc1b6c8d0643823e77b2de4a9ff26a/erato-gb.exe.obj \
 -SUBSYSTEM:console,6.0 -lldmingw -ALTERNATENAME:__image_base__=__ImageBase \
 /home/hamada/.cache/zig/o/8718870ddce7bdf4f0e9675b57895656/crt2.obj \
 /home/hamada/.cache/zig/o/9ea06d59d5ff1c3cc2c5527c624a0d40/mingw32.lib \
 /home/hamada/.cache/zig/o/96f699c362e3d5df24a0ceb679f3ac13/c++abi.lib \
 /home/hamada/.cache/zig/o/f0360665c750cdf9f3dc2f11e9eaed46/c++.lib \
 /home/hamada/.cache/zig/o/160324609ee49dec29dc33cc2fbe2043/unwind.lib \
 /home/hamada/.cache/zig/o/e74eb35e714a69c162be396e69facffe/compiler_rt.lib \
 /home/hamada/.cache/zig/o/948ff3835aaaf543960418c6e19273b1/gdi32.lib \
 /home/hamada/.cache/zig/o/b82fabc2a7ad5a0470abeabf5ba256e0/user32.lib \
 /home/hamada/.cache/zig/o/1ad6ad7d0248fd9fd8bef9a66b31282e/shell32.lib \
 /home/hamada/.cache/zig/o/2a3ba36174ed681f446aa16989ab5821/api-ms-win-crt-conio-l1-1-0.lib \
 /home/hamada/.cache/zig/o/54b4970eed635cd3316bd779b37aad3c/api-ms-win-crt-convert-l1-1-0.lib \
 /home/hamada/.cache/zig/o/ce9e17f2ebd7956b167b54d302343946/api-ms-win-crt-environment-l1-1-0.lib \
 /home/hamada/.cache/zig/o/4bdd3dc6a1ef6bbf83f3c9323836a174/api-ms-win-crt-filesystem-l1-1-0.lib \
 /home/hamada/.cache/zig/o/943870a8a7f2dcec811f65869edfb91c/api-ms-win-crt-heap-l1-1-0.lib \
 /home/hamada/.cache/zig/o/45c3ac7c81838111948ec5fbce82ddcc/api-ms-win-crt-locale-l1-1-0.lib \
 /home/hamada/.cache/zig/o/11204ba02ed38aa2141bb542ec462339/api-ms-win-crt-math-l1-1-0.lib \
 /home/hamada/.cache/zig/o/e1c9f27884dcb4ebd6709797637ac6c9/api-ms-win-crt-multibyte-l1-1-0.lib \
 /home/hamada/.cache/zig/o/f070c93d4b8f873fe4fb355f4bf833e4/api-ms-win-crt-private-l1-1-0.lib \
 /home/hamada/.cache/zig/o/504a8c440219a8d0bd6b7e818281e2e3/api-ms-win-crt-process-l1-1-0.lib \
 /home/hamada/.cache/zig/o/8e04eee5f8de1850d6a82010e188bb2e/api-ms-win-crt-runtime-l1-1-0.lib \
 /home/hamada/.cache/zig/o/035eb9023915240d6c78a32a79924944/api-ms-win-crt-stdio-l1-1-0.lib \
 /home/hamada/.cache/zig/o/bf248f7fda48ac14a55dbec262f7ec88/api-ms-win-crt-string-l1-1-0.lib \
 /home/hamada/.cache/zig/o/ab8f4cd9fdb9d3d4d6c13e07f39e2173/api-ms-win-crt-time-l1-1-0.lib \
 /home/hamada/.cache/zig/o/d5d228244ca0da1ac40a6f77ebb2796f/api-ms-win-crt-utility-l1-1-0.lib \
 /home/hamada/.cache/zig/o/f62d528a1199214a9ff6e94a336b557e/advapi32.lib \
 /home/hamada/.cache/zig/o/491767e7c66bddc7befc7fbf7bfe2502/kernel32.lib \
 /home/hamada/.cache/zig/o/5ce053b0ea7e32bd22b4b0cc4cd06045/ntdll.lib

It’s absolutely not clear to me what’s wrong with dawn.o and dawn_proc.o especially since these are generated by the very command that fails. Does anyone have any insight on what I should look at or what I am missing?

Thanks!

A guess is that it is related with libzdawn.a (and this lib might contain dawn.o and dawn_proc.o). I am guessing that, because windows extensions for libraries are .lib instead of .a and for objects .obj instead of .o. A reason getting that might be that .target is not set when building these objects and library.

If my guess is not helpful, posting your build.zig might help find out what is going on.

Welcome to ziggit :slight_smile: