Skip to content

Compiling on Windows

Chadow edited this page Feb 15, 2024 · 5 revisions

Contents

  1. Requirements
  2. Building Gosu
  3. Building The Wrapper
  4. Distributing

Requirements

Compilation on Windows is slightly more complex that those of MacOS or Linux, so bear with me.

We'll use MSYS2 for most steps except when building Gosu. In MSYS2, install the following packages:

ruby
git
make
cmake
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-dlfcn
mingw-w64-ucrt-x86_64-binutils # Optional, if you want to strip the binary

Building Gosu

Get the source code from the releases page then extract it on some place. Then build the Visual C++ project under windows/Gosu.sln, you can use either msbuild or vcexpress from the command line to build it:

msbuild Gosu.sln /p:Configuration=Release

or

vcexpress Gosu.sln /p:Configuration=Release

Note the generated Gosu.lib and gosu-ffi.lib, we'll need them later. Oh and rename Gosu.lib to gosu.lib.

Building The Wrapper

Get the source code from releases page and extract it, on the vendor directory, create a directory named gosu, then move the ffi directory of Gosu there, and make another directory named lib64, place the .lib files there. Your final directory structure should look like this:

.
├── assets
├── include
├── scripts
│   └── mruby
├── src
└── vendor
    ├── gosu
    │   ├── ffi
    │   │   └── Various headers needed for compilation...
    │   └── lib64
    │       ├── libgosu-ffi.lib
    │       └── libgosu.lib
    ├── mruby
    ├── physfs
    └── whereami

Then, on a MSYS2 console, run the following:

mkdir build
cd build
cmake ..
make

And that's it!

Distributing

You'll need some .dlls for it work correctly, here's the list:

  • gosu-ffi.dll: built when we built Gosu, on the lib64/ directory.
  • SDL2.dll: on the lib64/ directory.
  • libstdc++-6.dll: on msy64/ucrt64/.
  • libgcc_s_seh-1.dll: on msy64/ucrt64/.
  • libwinpthread-1.dll: on msy64/ucrt64/.
Clone this wiki locally