[Major Feature] Cross-compilation for Windows from Linux #162

Closed
opened 2025-12-29 03:54:01 +00:00 by john · 1 comment
Owner

Summary

Currently building Windows releases requires booting a Windows machine. This friction discourages frequent releases and slows iteration.

Goal

Enable cross-compilation from Linux to produce Windows executables, eliminating the need for a Windows development environment.

Approach Options

  1. MinGW-w64 Cross Compiler

    • x86_64-w64-mingw32-g++ toolchain
    • May need to cross-compile SFML and dependencies
    • Proven approach used by many projects
  2. Docker-based Windows Build

    • Container with Wine + MSVC or MinGW
    • Reproducible build environment
    • Could integrate with CI
  3. Zig as Cross-Compiler

    • zig cc can target Windows from Linux
    • Handles libc differences automatically
    • Newer approach, less proven for complex projects

Dependencies to Cross-Compile

  • SFML (graphics, audio, windowing)
  • Python 3.12 (embedded interpreter)
  • libtcod (roguelike utilities)

Success Criteria

  • make windows from Linux produces working .exe
  • AppImage and Windows zip can be built from same Linux machine
  • No Windows boot required for releases

Notes

The 7DRL 2025 release shipped both AppImage (Linux) and Windows zip, proving both targets work. The goal is just to build both from one environment.

  • Packaging variants issue (light vs full stdlib)
  • Release automation
## Summary Currently building Windows releases requires booting a Windows machine. This friction discourages frequent releases and slows iteration. ## Goal Enable cross-compilation from Linux to produce Windows executables, eliminating the need for a Windows development environment. ## Approach Options 1. **MinGW-w64 Cross Compiler** - `x86_64-w64-mingw32-g++` toolchain - May need to cross-compile SFML and dependencies - Proven approach used by many projects 2. **Docker-based Windows Build** - Container with Wine + MSVC or MinGW - Reproducible build environment - Could integrate with CI 3. **Zig as Cross-Compiler** - `zig cc` can target Windows from Linux - Handles libc differences automatically - Newer approach, less proven for complex projects ## Dependencies to Cross-Compile - SFML (graphics, audio, windowing) - Python 3.12 (embedded interpreter) - libtcod (roguelike utilities) ## Success Criteria - `make windows` from Linux produces working .exe - AppImage and Windows zip can be built from same Linux machine - No Windows boot required for releases ## Notes The 7DRL 2025 release shipped both AppImage (Linux) and Windows zip, proving both targets work. The goal is just to build both from one environment. ## Related - Packaging variants issue (light vs full stdlib) - Release automation
john closed this issue 2026-01-09 02:16:32 +00:00
Author
Owner

Summary of Windows cross-compilation fixes:

File Change
deps/platform/windows/platform.h __PLATFORM_SET_PYTHON_SEARCH_PATHS changed from 0 to 1
src/McRFPy_API.cpp Added #include , replaced PyRun_SimpleFile with std::ifstream + PyRun_SimpleString
src/main.cpp Replaced PyRun_SimpleFile with std::ifstream + PyRun_SimpleString, removed debug statements
CMakeLists.txt Added -include for PC/pyconfig.h, added Py_PYCONFIG_H define, added MCRF_WINDOWS_CONSOLE option
Makefile Added windows-debug target

Key technical issues resolved:

  1. PyRun_SimpleFile hangs with MinGW-compiled code - fixed with std::ifstream + PyRun_SimpleString
  2. MS_WINDOWS not defined (pyconfig.h include guard mismatch) - fixed with -include flag
  3. Python module search paths not set on Windows - fixed by enabling __PLATFORM_SET_PYTHON_SEARCH_PATHS
Summary of Windows cross-compilation fixes: | File | Change | |----------------------------------|-------------------------------------------------------------------------------------------------| | deps/platform/windows/platform.h | __PLATFORM_SET_PYTHON_SEARCH_PATHS changed from 0 to 1 | | src/McRFPy_API.cpp | Added #include <fstream>, replaced PyRun_SimpleFile with std::ifstream + PyRun_SimpleString | | src/main.cpp | Replaced PyRun_SimpleFile with std::ifstream + PyRun_SimpleString, removed debug statements | | CMakeLists.txt | Added -include for PC/pyconfig.h, added Py_PYCONFIG_H define, added MCRF_WINDOWS_CONSOLE option | | Makefile | Added windows-debug target | Key technical issues resolved: 1. PyRun_SimpleFile hangs with MinGW-compiled code - fixed with std::ifstream + PyRun_SimpleString 2. MS_WINDOWS not defined (pyconfig.h include guard mismatch) - fixed with -include flag 3. Python module search paths not set on Windows - fixed by enabling __PLATFORM_SET_PYTHON_SEARCH_PATHS
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
john/McRogueFace#162
No description provided.