sm64pc / sm64ex

Fork of https://github.com/sm64-port/sm64-port with additional features.
1.56k stars 480 forks source link

Successful cross-compilation from ArchLinux targetting Windows x64 #491

Closed Microeinstein closed 9 months ago

Microeinstein commented 2 years ago

Hi, I just wanted to inform that I managed to cross-compile from ArchLinux to Windows x64, and I would like the Wiki to be extended of the following information:

Procedure

  1. Requirements
    • python
    • audiofile
    • mingw-w64 (meta package)
    • aur/mingw-w64-environment
    • aur/mingw-w64-sdl2
    • aur/mingw-w64-glew
    • (baserom.ver.z64)
  2. Hacks
    • make a symlink to libglew32.dll.a as libglew32.a $ sudo ln -s /usr/x86_64-w64-mingw32/lib/libglew32{.dll,}.a
  3. Export compiling tools [this technique is specific for your Makefile]
    • $ source mingw-env x86_64-w64-mingw32 (see script)
    • $ export CROSS=/usr/x86_64-w64-mingw32/bin/ (keep trailing slash)
  4. Compile using favourite options (must use SDL2 for most things)
    $ flags=(
      VERSION=us
      WINDOWS_BUILD=1
      TARGET_BITS=64
      BETTERCAMERA=1
      NODRAWINGDISTANCE=1
      TEXTURE_FIX=1
      EXT_OPTIONS_MENU=1
      DISCORDRPC=1
    )
    $ make "${flags[@]}"
  5. Package
    • copy required dlls into build directory $ cp /usr/x86_64-w64-mingw32/bin/glew32.dll build/us-pc

Full solution

#!/bin/bash
# This script is not meant to be executed directly
sudo pacman -Syu
sudo pacman -S base-devel git pacman audiofile
aurhelper -S mingw-w64{,-{environment,sdl2,glew}}
wenv=x86_64-w64-mingw32  # must not contain spaces or special characters

sudo ln -s /usr/$wenv/lib/libglew32{.dll,}.a

git clone -b nightly --single-branch https://github.com/sm64pc/sm64ex.git
cd sm64ex
git apply "enhancements/60fps_ex.patch" --ignore-whitespace --reject
ver=us
cp somewhere/baserom.$ver.z64 .

source mingw-env $wenv
export CROSS=/usr/$wenv/bin/
flags=(
  VERSION=$ver
  WINDOWS_BUILD=1
  TARGET_BITS=64
  BETTERCAMERA=1
  NODRAWINGDISTANCE=1
  TEXTURE_FIX=1
  EXT_OPTIONS_MENU=1
  DISCORDRPC=1
)
make "${flags[@]}"

cd build/$ver-pc
cp /usr/$wenv/bin/glew32.dll .
fgsfdsfgs commented 9 months ago

Thanks for the information. I'll close this, people will be able to find it in closed issues if they need to.