Skip to content

Instantly share code, notes, and snippets.

@camila314
Created January 17, 2025 01:23
Show Gist options
  • Select an option

  • Save camila314/cd82a059fe35a6eb93ebe897f6a21dab to your computer and use it in GitHub Desktop.

Select an option

Save camila314/cd82a059fe35a6eb93ebe897f6a21dab to your computer and use it in GitHub Desktop.
Cross Compile Geode Mod to Windows on Mac or Linux

Setup

Step 1. install lld

brew install lld

or for linux, sudo apt-get install lld

Step 1. get xwin

cargo install xwin

Step 2. download windows sdks

we shall use ~/.xwin.

xwin --accept-license splat --use-winsysroot-style --preserve-ms-arch-notation --include-debug-libs --include-debug-symbols --output ~/.xwin

Step 3. get geode binaries

geode sdk install-binaries -p win

Step 4. create toolchain file

save this file as a .cmake file (e.g ~/.local/windows.cmake):

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_SYSTEM_PROCESSOR AMD64)

set(CMAKE_C_COMPILER clang-cl)
set(CMAKE_CXX_COMPILER clang-cl)

set(CMAKE_CXX_FLAGS_INIT "--target=x86_64-pc-windows-msvc /winsysroot $ENV{HOME}/.xwin -fuse-ld=lld")
set(CMAKE_EXE_LINKER_FLAGS_INIT "/manifest:no /winsysroot:$ENV{HOME}/.xwin")
set(CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT})
set(CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT})

set(CMAKE_C_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})

set(CMAKE_C_STANDARD_LIBRARIES "")
set(CMAKE_CXX_STANDARD_LIBRARIES "")

set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)

Use

use -DCMAKE_TOOLCHAIN_FILE=<toolchain file> when making your build folder. then build normally. e.g:

cmake -B build-win -DCMAKE_TOOLCHAIN_FILE=~/.local/windows.cmake
cmake --build build-win
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment