-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cross compiling sokol_app.h for windows #74
Comments
Just a couple of tidbits before I'll get around to actually try the result on Windows: Slightly different scenario (a Zig+sokol project with a build.zig), but in the pacman.zig project (https://github.com/floooh/pacman.zig), I can compile a Windows exe on macOS with:
This will link the following Windows DLLs: Lines 251 to 260 in 7e23aa3
Also, I think this uses MUSL instead of the MSVC C library (e.g. it shouldn't require the ucrtbase.dll at runtime). I did not yet actually try running this executable on Windows, but I will check this later (not today though). For a C application compiled with Zig I can imagine that there will be problems with main() vs WinMain() entry points (sokol_app.h uses WinMain on Windows, unless Zig can be instructed to build a WinMain executable via a 'Target.subsystem', not sure how that's activated from the cmdline though, and I also didn't experiment with this yet: https://ziglang.org/documentation/master/std/#std.builtin.subsystem PS: for the On Visual Studio the better fix (IMHO) is to use static linking for the C runtime (see: https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170). I don't know if this option is available on Zig. But what should definitely work is to statically link with MUSL (which seems to be the case when using the target |
Btw that cross-compiled pacman exectuable (via |
Cross-compiling for Windows target in Zig defaults to MinGW, the reason being indisputable. However, it still lacks some support for Windows libraries in a non-Windows environment. Unlike msvc-wine(docker), I tried using xwin with zig (Linux/macos/Windows) hermetic building exclusively to msvc and linking extra Windows libraries (vsruntime + winsdk) C and C++. |
I have a sokol app written in C that I would like to cross compile from mac to windows. (there is no zig code, I'm just using zig as a C cross compiler)
building with the following command produces an exe that shows a "missing ucrtbase.dll" error when launched on windows 7.
I tried instead compiling these other ways but they each produced other errors:
let me know if you need a project zip to reproduce.
The text was updated successfully, but these errors were encountered: