windows_install.rdoc

Path: doc/windows_install.rdoc
Last Update: Thu Mar 12 22:45:15 -0400 2009

Compiling Rubygame on Windows

(For the most up-to-date version of this document, see the Rubygame wiki: rubygame.wiki.sourceforge.net/win32_compile)

This document gives some helpful guidelines to for compiling and installing Rubygame on Microsoft Windows. However, these instructions are not perfect, so they might not work for you. If you use this guide, we‘d love to hear about what worked and what didn‘t; just send a message to the rubygame-users mailing list!

The usual caveats apply: follow these instructions at your own risk and so forth. Please direct comments or questions to the Rubygame user's mailing list.

Step 1: Gather Dependencies

  • You‘ll need a build environment for Windows. In this guide, we‘ll use MinGW.
    • Grab MinGW-NNN.exe (e.g. MinGW-5.12.exe) from the downloads page and install it. (Note: you might need to expand the "MinGW" section to see the MinGW-NNN.exe files.)
    • Optional, but recommended: install MSYS-NNNN.exe (e.g. MSYS-1.0.10.exe) from the same page as above. (You might have to expand the MSYS section.)
    • Add the full path to the compiler executible to your system PATH if it isn‘t there already. You should be able to type gcc -v at a command line and see a version number.
  • Download Ruby, the language itself. The easiest option here is the one-click installer. This will install Ruby and a number of useful libraries without any hassle.
  • SDL. In the Development Libraries section (near the bottom of the page), grab the SDL-devel-1.2.??-VC6.zip file. (The VC6 package is just fine, even though we‘re using with MinGW to compile.)

The rest are optional dependencies, but highly recommended. If you don‘t have them, you won‘t be able to use certain features of Rubygame.

  • SDL_image. Grab the Win32 binary package with ‘devel’ in the name.
  • SDL_mixer. Just like before, grab the Win32 binary package with ‘devel’ in the name.
  • SDL_ttf. Again, get the Win32 binary package with ‘devel’ in the name
  • SDL_gfx. This is the trickiest dependency, because there is currently no official package for a precompiled version of SDL_gfx. If you are able to compile this yourself, great! Otherwise, some nice features of Rubygame have to be disabled; make sure you add the —no-gfx flag when you get to the "Set up environment variables" section, below.

Once you have downloaded everything, extract each archive into a convenient location on your hard drive. You‘ll thank yourself later if you use a short path with no spaces in it. For this example, we‘ll unzip everything under C:\src\.

Next, copy the *.dll file from each library‘s folder into C:\windows\system32\. This will allow the libraries to be detected properly later on.

Step 2: Get Rubygame

If you haven‘t already, download the latest Rubygame source from the download page. If you‘re feeling adventurous, you could try the in-development code from the Git repository. You can decompress the .tar.bz2 file with either MSYS’ tar (tar xvjf rubygame-2.0.0.tar.bz2) or a program like 7zip.

Extract the source into another folder of your choice, such as C:\src\rubygame.

Step 3: Set up environment variables

Environment variables are used to configure the build process for your system; it helps the compiler to locate the headers and libraries it needs to compile Rubygame.

Create a text file in your Rubygame directory called "envsetup.bat". In it, use code based on the following to set your variables. Be sure to replace ’\src\’ (lines 3-7) with the path to where you unpacked the libraries.

 set CC=gcc
 set CFLAGS=-DHAVE_ISINF -D_MSC_VER=1200
 set CFLAGS=%CFLAGS% -I \src\SDL-1.2.11\include
 set CFLAGS=%CFLAGS% -I \src\SDL_gfx-2.0.15
 set CFLAGS=%CFLAGS% -I \src\SDL_image-1.2.5\include
 set CFLAGS=%CFLAGS% -I \src\SDL_mixer-1.2.7\include
 set CFLAGS=%CFLAGS% -I \src\SDL_ttf-2.0.8\include

 set LDSHARED=gcc -shared
 set LINK_FLAGS=-L \windows\system32 -lSDL
 set LIBRUBYARG_SHARED=-L \ruby\bin -lmsvcrt-ruby18

The -L parameter for LIBRUBYARG_SHARED may be different if you installed Ruby to a path other than C:/ruby.

Step 4: Compile and install Rubygame

Open a command prompt and navigate to the root of your Rubygame source directory. Type:

 envsetup.bat
 rake install

IMPORTANT: If you are missing an optional library (such as SDL_gfx), you must disable optional features by passing a "no-???" command to rake before the word "install". For example, to disable features that depend on SDL_gfx, you would type this instead of the above:

 envsetup.bat
 rake no-sdl-gfx install

If all goes well, you have built and installed Rubygame. Try to execute require ‘rubygame‘ in an irb session and run the provided samples to ensure that everything is acceptable.

(Thanks to Ash Wilson (smashwilson) for contributing the original version of these instructions.)

[Validate]