Install

Caution: Ebitengine on FreeBSD is not tested well by the author.

Desktop Environment

Ebitengine 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.

Installing Go

Install Go on your machine. Ebitengine requires Go 1.22 or later.

Note that you do NOT need a C compiler for Ebitengine on Windows.

Installing a C compiler

A C compiler is required as Ebitengine 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 the following 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 install commandline tools.

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

apt install gcc

Use pkg.

pkg install clang

Installing dependencies

Debian / Ubuntu

sudo apt install libc6-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev libasound2-dev pkg-config

Fedora

sudo dnf install mesa-libGL-devel mesa-libGLES-devel libXrandr-devel libXcursor-devel libXinerama-devel libXi-devel libXxf86vm-devel alsa-lib-devel pkg-config

Solus

sudo eopkg install libglvnd-devel libx11-devel libxrandr-devel libxinerama-devel libxcursor-devel libxi-devel libxxf86vm-devel alsa-lib-devel pkg-config

Arch

sudo pacman -S mesa libxrandr libxcursor libxinerama libxi pkg-config

Alpine

sudo apk add alsa-lib-dev libx11-dev libxrandr-dev libxcursor-dev libxinerama-dev libxi-dev mesa-dev pkgconf

Void

sudo xbps-install libXxf86vm-devel pkg-config
pkg install alsa-lib libxcursor libxi libxinerama libxrandr mesa-libs pkgconf

Confirming your environment

You can check whether you have a correct environment by executing an example:

go run github.com/hajimehoshi/ebiten/v2/examples/rotate@latest

If you see this window with a rotating Gophers image, congratulations! You have a correct environment to use Ebitengine!

Rotate example

If you are using the Windows Subsystem for Linux (WSL), you must set the environment variable GOOS=windows when executing the go run command.

GOOS=windows go run github.com/hajimehoshi/ebiten/v2/examples/rotate@latest

Running a program with Ebitengine

Ebitengine can be used as a usual Go library. Go command automatically installs Ebitengine when your program uses Ebitengine.

First, create your local module.

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

# Initialize go.mod by `go mod init`.
go mod init github.com/yourname/yourgame

Use URL for your module name like github.com/yourname/yourgame. Actually, any module name like example.com/m is fine as long as you don't plan to share this publicly. You can change the module name anytime later.

Add main.go with this content:


Run go mod tidy to add dependencies to your go.mod:

go mod tidy

Finally, run go run to execute your program.

go run .

You will be able to see a window with a message:

Hello, World!