windows_install.rdoc

Path: doc/windows_install.rdoc
Last Update: Sat Apr 21 15:53:17 -0400 2007

Compiling Rubygame on Windows

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 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, you‘ll want to create a directory for the DLLs and copy the .dll file from the lib subdirectory of each extracted component there (except SDL_gfx, as noted above). We‘ll use a new directory, C:\dlls\. Add this location to your system PATH — Windows searches the PATH for libraries as well as executables.

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 Subversion 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, and ’\dlls’ (line 10) with the path where you put the DLLs.

 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=ld -shared
 set LINK_FLAGS=-L \dlls -lSDL
 set LIBRUBYARG_SHARED=-L #{TOPDIR}/bin -l$(RUBY_SO_NAME)

 set RUBYGAME_CONFIG=--no-sdl-config

IMPORTANT: If you are missing an optional library (such as SDL_gfx), you need to add some extra flags on to the ‘RUBYGAME_CONFIG=…’ line. The flags you must add are of the style ’—no-????’ (without quotes), where ???? is the name of the missing library, dropping the ‘SDL_’ from in front. So, if you don‘t have SDL_gfx, the last line of your envsetup.bat should be this:

 set RUBYGAME_CONFIG=--no-sdl-config --no-gfx

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

Congratulations! 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 these instructions.)

[Validate]