Skip to content

Commit

Permalink
Add Linux to Windows cross-compilation script.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaphula committed Aug 1, 2024
1 parent 56d1c1f commit 49df830
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,17 @@ Github repository for egui-sdl2-event.

`cargo run --bin egui-sdl2-event-example`

## Cross compile from Linux to Windows with static linking

1. Download `SDL2-devel-2.XX.X-mingw.zip` from [here](https://github.com/libsdl-org/SDL/releases) and extract to your
specified location. Best to use the same version that `rust-sdl2` uses.
2. Install Windows toolchain target with `rustup target add x86_64-pc-windows-gnu`
3. Install `mingw` cross-compiler to your system, for Arch systems the package to install should be `mingw-w64-gcc`
4. Edit the [egui-sdl2-event-example/cross_compile_windows.sh](egui-sdl2-event-example/cross_compile_windows.sh) script
to match your system's paths and run it.
5. You should now have windows executable in your `target/x86_64-pc-windows-gnu/release/` which you can run with `wine`.
I don't have a Windows machine at the moment, so I cannot verify that it works on real Windows machine, yet.




4 changes: 0 additions & 4 deletions egui-sdl2-event-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ sdl2 = { version= "0.37.0", features = ["raw-window-handle", "bundled", "static
egui-sdl2-event = { path = "../lib" }
egui-wgpu = "0.28.1"
egui = "0.28.1"
# wgpu = "22.0.0"
pollster = "0.2.5"



8 changes: 8 additions & 0 deletions egui-sdl2-event-example/cross_compile_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# #!/bin/bash
# Edit this to match the SDL2 mingw development files you downloaded and extracted somewhere:
MINGW_SDL2_LIB_DIR=" /home/${USER}/lib/SDL2-2.30.5/x86_64-w64-mingw32/lib/"

# Edit these to match your system's mingw cross-compiler locations:
MINGW_GCC_PATH="/usr/bin/x86_64-w64-mingw32-gcc"
MINGW_AR_PATH="/usr/x86_64-w64-mingw32/bin/ar"
RUSTFLAGS="-L${MINGW_SDL2_LIB_DIR}" CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="${MINGW_GCC_PATH}" AR="${MINGW_AR_PATH}" cargo build --release --target x86_64-pc-windows-gnu

0 comments on commit 49df830

Please sign in to comment.