Oops, I accidentally a Windows support


So, I finally managed to do it: I got some form of Windows support working with a game of mine that isn't built using a game engine that allows me to do so with a simple click. Technically it shouldn't be such a massive accomplishment considering I built Robot Ricochet with libraries that already support Windows, but it still took way longer than one might have expected.

For context, I am a 100% Linux user. The only Windows machine I have is a work laptop and I don't do anything personal on it in order to keep work and personal life separated. I'm also doing that to cover my backside in case someone would decide that my use of company resources means my personal projects suddenly belong to the company. I don't expect that would happen, but even the mental health benefit of shutting off the work laptop at the end of work is worth it. Anyway, this means that I effectively don't have a Windows system to do Windows development or testing.

This means that if I want to develop something for both Linux and Windows, I have to rely on cross-compilation tooling to build Windows EXEs on my Linux system. Since Robot Ricochet is written in Rust and Rust supports multiple targets, that would seem an easy task. However, Robot Ricochet is built on top of SDL2, which means that it needs to link with dependencies written in C/C++ and this makes the process a bit more complicated. Firstly, it means that I need a GCC compiler that uses MINGW64 for Windows cross-compilation and I need the SDL2 library DLLs to link to.

Particularly the last step can be fairly annoying to do. I tried setting up the build pipeline on Arch Linux previously, but installing the MINGW64 dependencies via AUR meant very long and annoying builds and despite some effort I wasn't able to get it to work. But, as it happens I have recently jumped ship over to Fedora and it seems like the setup is way easier on Fedora.

Since I use Fedora Silverblue, I manage my development environment using Toolbx in order to create containerized environments that I can create and destroy at will. This also gave me extra guarantees that if I somehow screwed everything up, I would only lose the container and could recreate it quickly.

$ toolbox create windows-build

Since the Fedora repositories carry all of the MINGW64 dependencies I need, I just had to tell DNF to fetch them for me:

$ sudo dnf install mingw64-gcc mingw64-SDL2 mingw64-SDL2_image mingw64-SDL2_mixer mingw64-SDL2_ttf

Since I already had my Rust toolchain installed, I just needed to download the target:

$ rustup target add x86_64-pc-windows-gnu

And then run the build:

$ cargo build --release --target x86_64-pc-windows-gnu

Then just copy all of the necessary stuff into a folder:

$ mkdir -p dist-win64
$ cp -r data dist-win64/data
$ cp target/x86_64-pc-windows-gnu/release/robot-ricochet.exe dist-win64/robot-ricochet.exe
$ cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/*.dll dist-win64/

Install Wine to test:

$ sudo dnf install wine
$ wine dist-win64/robot-ricochet.exe

And voila:

Robot Ricochet running on Wine

This means that I now have a method to build Windows releases and test them in a fairly reproducible way. And as long as I mostly stick to Rust dependencies that can be linked statically, I should have relatively few DLLs to worry about. Right now the Windows version is even a slight bit smaller than the Linux version, although I don't have guarantees that it actually works in an actual Windows environment.

But the nice thing is that if I decide to make a game that I absolutely want to release on Windows, I don't need to involve any Windows environment and can simply set up a cross-compiler to handle that for me and I don't need to crack open a full-blown game engine for every such game I want to make. For a proper game release I would likely need to at least get someone to test out if the release works, but I don't see why this approach wouldn't work with a bit of tuning.

That is all for now, if someone wants to try out the Windows version they are most welcome to report issues. However, as it stands the Windows support is still not a high priority and I don't have the means to do proper testing on it. But, if it happens to work, it now exists for people to enjoy.

Files

robot-ricochet-win64.zip 22 MB
Version 1.0.1 Dec 26, 2021
robot-ricochet-win64.zip 22 MB
Version 1.0.1 Dec 26, 2021

Get Robot Ricochet

Leave a comment

Log in with itch.io to leave a comment.