Cross-Compiling From Windows

Hello! Been struggling with this for a while now. What I have is a C/C++ game with a build.zig that works great when built natively on windows, x86_64-linux-gnu and x86_64-macos. What I’d like to do is cross-compile my game to these platforms and others all from windows.

First up is just getting the Linux one to work, because I can use WSL to get access to the build files.
I copied the dependency libraries and headers out of my ubuntu install into a cross-compile folder.

zig build -Dtarget=x86_64-linux … builds!
I copy the binary over to the WSL machine to test and it can’t find it… come to find out it built with MUSL, not GNU, so I go back…
zig build -Dtarget=x86_64-linux-gnu … fails
The erors I get is compile-time missing symbols for _isoc23_stroll and similar. These are defined inside zig/lib/libc but not being picked up?
So I tried building “natively” on WSL… same error. Until I apt-installed GCC, now x86_64-linux-gnu builds and runs on WSL. THis leads me to believe that there are missing system folders in my cross-compile directory.

I copied the folder that appears in WSL’s zig libc command out, and then added exe.AddSystemLibraryPath to point to it but I get the same error.

Am I on the right track here? What am I missing?

It seems that a potentially related issue has been fixed just 6 hours ago: zig c++ link error when targetting older glibc · Issue #17536 · ziglang/zig · GitHub
So I suggest you wait a day or so until that version hits Download ⚡ Zig Programming Language and try again.


ha yes was just coming in here to say this I think you may be right, because targeting 2.38 does build without the errors. I’ll close this because it will most likely work

manually applying the fix to the libc file does indeed fix the issue, cross compling works now!