Skip to content

Getting Started on Linux

Not Important edited this page Sep 4, 2023 · 63 revisions

Getting Started on Linux

Please help us keep this information up-to-date! :)

Dependencies

To install and use Gosu on Linux, you need the following packages (the names will be slightly different in every distribution):

libsdl2-dev, libgl1-mesa-dev, libgmp-dev, libfontconfig1-dev

Ubuntu (last tested on Ubuntu 22.04 with Gosu 1.4.6) / Linux Mint (last tested on Linux Mint 17.3) / elementary OS / Pop!_OS

# Dependencies for both C++ and Ruby
sudo apt-get install build-essential libsdl2-dev libgl1-mesa-dev \
                     libgmp-dev libfontconfig1-dev

# To install Ruby itself - if you are using rvm or rbenv, please skip this step
sudo apt-get install ruby-dev

# If you are using a Ruby version manager (i.e. rvm or rbenv)
gem install gosu
# If you are using system Ruby, you will need "sudo" to install Ruby libraries (gems)
sudo gem install gosu

See this forum thread for another detailed guide.

Debian 8 with Nvidia GPU

Please see this post on the Gosu forum if you run into trouble installing Gosu or anything else that uses OpenGL.

Arch Linux/Manjaro (last tested on 2020-11-15 with Gosu 0.15.2)

# Gosu's dependencies for both C++ and Ruby
sudo pacman -S pango sdl2 sdl2_ttf pkg-config

# To install Ruby
sudo pacman -S ruby

Fedora (last tested on Fedora 38 with Gosu 1.4.6)

# Gosu's dependencies for both C++ and Ruby
sudo dnf groupinstall --assumeyes "Development Tools"
sudo dnf install --assumeyes mesa-libGL-devel gcc-c++ redhat-rpm-config SDL2-devel fontconfig-devel

# To install Ruby
sudo dnf install --assumeyes ruby-devel

# Install Gosu
gem install gosu

Mageia Linux (last tested 2019-11-27 with Gosu 0.14.5)

# Gosu's dependencies for both C++ and Ruby.
su
dnf install ruby ruby-devel g++ gcc lib64sdl2.0_0 lib64mesavulkan-devel lib64mesagl1-devel lib64sdl2.0-devel lib64fontconfig-devel
exit
# To install Gosu
gem install gosu

Gentoo Linux (last tested 2017-11-14 with Gosu 0.12.1)

# Gosu's dependencies for both C++ and Ruby.
# Ensure you have the 'opengl' USE flag set globally or at least for media-libs/libsdl2.
sudo emerge -av media-libs/mesa

# To install Ruby
sudo emerge -av dev-lang/ruby

OpenSUSE (last tested on OpenSUSE 13.1 with Gosu 0.8.3)

# General development tools
sudo zypper install --type pattern devel_basis
# Gosu's dependencies for both C++ and Ruby
sudo zypper install libSDL2-devel

# To install the Ruby headers
sudo zypper install ruby-devel

# If you are using rvm or rbenv, do not use 'sudo'
sudo gem install gosu

Compiling Gosu for C++

To compile Gosu, cd into the cmake subdirectory and run:

mkdir -p build
cd build
cmake ..
make
sudo make install

There is no uninstall target, so if you want to clean up you will need to manually delete the files listed by make install.

Using Gosu in C++ with CMake

Have a look at the examples. The example CMakeLists.txt files are short, commented and straightforward, and can be used as a starting point for your own Gosu C++ games:

https://github.com/gosu/gosu/blob/master/examples/Tutorial/CMakeLists.txt

Clone this wiki locally