Skip to content

Getting Started on Windows

刘宇峰 edited this page Oct 12, 2022 · 7 revisions

Getting Started on Windows

Installing Ruby/Gosu on Windows

Getting started with Ruby is very easy if you install Ruby from the Installer and install the DevKit. Install Gosu:

gem install gosu

You can work your way from here using the Ruby Tutorial if you want, or you can check out Gosu's own example games:

gem install gosu-examples
gosu-examples

If you are using WSL (the Windows Subsystem for Linux)...

...see the notes in this issue.

Setting up Visual C++

Download and extract the latest version of Gosu for Windows from the releases page.

There is a Visual C++ project under windows/Gosu.sln that will build Gosu itself, but also includes the C++ Tutorial game that you can run to verify that Gosu works.

Create a new Gosu game with Visual C++

Click File/New/Project and select 'Win32 project', then give it a name and in the application settings choose 'Empty project'.

MSVC++ new project window

MSVC++ Application Wizard

You can then add C++ code files to your project, for example the one from the C++ Tutorial.

Next, open the project options, select C/C++ options, Code Generation, and change the used library from "Multithreaded DLL" to "Multithreaded", and "Multithreaded Debug DLL" to "Multithreaded Debug", respectively, or you will get linker errors later. These options are only available after adding the first C++ source file.

MSVC++ code generation settings

To ensure that your EXE file can find SDL2.dll and your images and sound files, you should also change your project's output directory for both configurations (Release/Debug) so that all files end up in the same place. (In this case I have copied all DLLs from Gosu's "lib" folder into the "examples" folder, and am building Tutorial.exe into this folder so that it can find everything.)

MSVC++ output directory

Once you have everything set up, you can follow the C++ Tutorial to learn about Gosu.

Gosu for C++ with MinGW

See this separate guide: Compiling in Windows using MinGW