Skip to content

Getting Started on Raspbian (Raspberry Pi)

Julian Raschke edited this page Apr 5, 2017 · 16 revisions

Getting Started on Raspbian (Raspberry Pi)

Note: This guide only applies to the original Raspberry Pi and the Raspbian Linux distribution. If you use a Raspberry Pi 2 or 3, please enable OpenGL and then follow the ‘normal’ instructions for Ubuntu/Debian here: Getting Started on Linux. Please also install Gosu using sudo gem install gosu --pre for now; the current stable version will not work.

In theory, Raspbian is 'just' another Linux distribution. However, its package manager is missing Gosu's (new) main dependency, SDL 2. There is a package called libsdl2-dev in the Debian Jessie repositories, but it comes without the RPI video driver and cannot be used to install Gosu.

You can follow these steps to install Ruby/Gosu anyway:

  1. Install Raspbian on an SD card, if you haven't already (downloads and instructions)

  2. In Raspbian, go to the SDL 2 download page and download the latest version in .tar.gz format. If you click "Save", it will be downloaded into /home/pi, which is what I will assume in the steps below.

  3. Also download the latest version of SDL_ttf into the same directory.

  4. Open a terminal and run:

    sudo apt-get install ruby ruby-dev build-essential libfreeimage-dev libopenal-dev libpango1.0-dev libsndfile-dev libudev-dev libasound2-dev
  5. Unpack and compile SDL 2. This will take roughly one hour to complete:

    tar zxvf SDL2-2.*.tar.gz
    cd SDL2-2.*
    ./configure --prefix=/opt/SDL2 --disable-video-x11
    make
    sudo make install

    If you are already using Raspbian Jessie, try this variant of the ./configure command instead:

    ./configure --host=armv7l-raspberry-linux-gnueabihf --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
  6. Unpack and compile SDL_ttf. This shouldn't take nearly as long.

    cd
    tar zxvf SDL2_ttf-2.*.tar.gz
    cd SDL2_ttf-2.*
    ./configure --prefix=/opt/SDL2 && make && sudo make install
  7. Install Gosu with the following command:

    sudo gem install gosu -- --with-cflags=-I/opt/SDL2/include/SDL2 --with-cppflags=-I/opt/SDL2/include/SDL2 --with-ldflags=\"/opt/SDL2/lib/libSDL2.a /opt/SDL2/lib/libSDL2_ttf.a\"
  8. Optional: Run the example games to verify that everything works.

    sudo gem install gosu-examples
    gosu-examples --fullscreen
  9. Optional: Clean up by deleting the SDL folders and .tar.gz files in your home directory.

Congratulations, you should now be able to run Ruby/Gosu games!

Note: One unresolved issue in Raspbian is that games started from a terminal will leak keystrokes into the terminal, and you might accidentally trigger commands while playing games (#213). You can use this handy tool to prevent this from happening.

Note: It is best to run all games in fullscreen mode on Raspbian, since windowed mode does not work as expected.