Install

Let's get the Ebiten source code and compile it.

Desktop Environment

Ebiten requires X Window system and you need to install a window manager like GNOME3. See the official manual. Note that you also need to do pkg install xorg.

Go

Install Go on your machine. Ebiten requires Go 1.12 or later.

Git

Git is required to get most of Go packages including Ebiten.

Option 1: The official Git installer

The official Git website is recommended. After installation, add the below values to PATH environment variable:

  • For 32bit, C:\Program Files\Git\bin
  • For 64bit, C:\Program Files (x86)\Git\bin

Option 2: Scoop

You also can get Git via Scoop.

scoop install git

Option 1: Homebrew

Homebrew is recommended.

brew install git

Option 2: The official Git installer

The official Git installer is also fine.

Use your distribution's package manager. The official website also says so. For example, on Ubuntu you can use apt:

apt install git

Use pkg.

pkg install git

C compiler

A C compiler is required as Ebiten uses not only Go but also C.

On the latest macOS, just type clang on your terminal and a dialog would appear if you don't have clang compiler. Follow the instruction to install it.

You might find an error when executing clang:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

In this case, run xcode-select --install and select commandline tools.

Use your distribution's package manager. For example, Ubuntu can use apt:

apt install gcc

Use pkg.

pkg install clang

You need to set some environment variables:

export C_INCLUDE_PATH=/usr/local/include:${C_INCLUDE_PATH}
export CPLUS_INCLUDE_PATH=/usr/local/include:${CPLUS_INCLUDE_PATH}
export LIBRARY_PATH=/usr/local/lib:${LIBRARY_PATH}

Dependencies

Debian / Ubuntu

sudo apt install libc6-dev libglu1-mesa-dev libgles2-mesa-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev libasound2-dev

Fedora

sudo dnf install mesa-libGLU-devel mesa-libGLES-devel libXrandr-devel libXcursor-devel libXinerama-devel libXi-devel alsa-lib-devel

Solus

sudo eopkg install libglu-devel libx11-devel libxrandr-devel libxinerama-devel libxcursor-devel libxi-devel alsa-lib-devel

Arch

sudo pacman -S mesa libxrandr libxcursor libxinerama libxi

OpenAL is required for Ebiten's audio package. Note that the openal package is pretty old and doesn't work. Install openal-soft instead.

pkg install openal-soft

Ebiten

Ebiten can be downloaded as a usual Go library. Ebiten is available both with and without Go modules.

Option 1: With Go modules

Go modules are available as of Go 1.11.

# Create a directory for your game.
mkdir yourgame
cd yourgame

# Initialize go.mod by `go mod`.
# Use URL for your package like `github.com/yourname/yourgame`.
# If you are not sure and don't plan to share it so far, `example.com/m` is fine.
go mod init example.com/m

Ebiten package is automatically downloaded when executing your program that imports github.com/hajimehoshi/ebiten. example.com/m is an arbitrary URL for local testing. Use your project's URL (e.g. github.com/yourname/yourproject) when you make this public.

For more details about Go modules, see the Wiki article.

Option 2: Without Go modules

Run go get.

go get github.com/hajimehoshi/ebiten/...

... means to install not only Ebiten but also its sub-packages (and their dependencies).

Run an example

Let's execute an example to check installation finished correctly.

Option 1: With Go modules

Move to the yourgame directory you made, and run:

go run -tags=example github.com/hajimehoshi/ebiten/examples/rotate

Option 2: Without Go modules

cd %USERPROFILE%\go\src\github.com\hajimehoshi\ebiten
go run -tags=example ./examples/rotate
cd $(go env GOPATH)/src/github.com/hajimehoshi/ebiten
go run -tags=example ./examples/rotate

go run compiles Go files and runs it immediately after the compilation. As the first compilation might take a little long time, please wait for a while. Note that you can see what is happening on the compilation process with -x option if you want.

If you see the window with a rotating Gophers picture, congratulations! You have succeeded to install Ebiten.

Note that -tags=example is needed to execute the examples as the Ebiten example packages require the build tag.

Rotate example