Install
インストール
Caution: Ebiten on FreeBSD is not tested well by the author.
注意: FreeBSD 上の Ebiten は、作者によってあまりテストされていません。
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
.
Ebiten を動かすためには X Window system が必要です。 GNOME3 のようなウィンドウマネージャをインストールする必要があります。公式マニュアルを参照してください。 pkg install xorg
を実行する必要があることに注意してください。
Go
Install Go on your machine. Ebiten requires Go 1.15 or later.
Go をインストールしてください。 Ebiten を動かすためには Go 1.15 以降が必要です。
Note that you do NOT need a C compiler for Ebiten on Windows.
Windows では、 C コンパイラは必要ありません。
C compiler
C コンパイラ
A C compiler is required as Ebiten uses not only Go but also C.
Ebiten は Go だけではなく C も使っているため、 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.
最新の macOS ならば、ターミナル上で clang
と入力すれば、 clang がまだインストールされていないのであれば、ダイアログが表示されます。指示に従ってインストールしてください。
You might find the following error when executing clang.
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.
その場合は xcode-select --install
を実行して、コマンドラインツールをインストールしてください。
Use your distribution's package manager. For example, Ubuntu can use apt
.
お使いのディストリビューションのパッケージマネージャを使ってください。例えば、 Ubuntu では apt
が使えます。
apt install gcc
Use pkg
.
pkg
を使ってください。
pkg install clang
Dependencies
依存ライブラリ
Debian / Ubuntu
sudo apt install libc6-dev libglu1-mesa-dev libgl1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxxf86vm-dev libasound2-dev pkg-config
Fedora
sudo dnf install mesa-libGLU-devel mesa-libGLES-devel libXrandr-devel libXcursor-devel libXinerama-devel libXi-devel libXxf86vm-devel alsa-lib-devel pkg-config
Solus
sudo eopkg install libglu-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
pkg install alsa-lib libxcursor libxi libxinerama libxrandr mesa-libs pkgconf
Ebiten
Ebiten can be used as a usual Go library. Go command automatically installs Ebiten when your program uses Ebiten.
Ebiten は通常の Go ライブラリとして使用できます。プログラムが Ebiten を使用していれば、 Go コマンドが自動的に Ebiten をインストールします。
First, create your local module.
最初に、ローカルモジュールを作ります。
# Create a directory for your game.
mkdir yourgame
cd yourgame
# Initialize go.mod by `go mod`.
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.
github.com/yourname/yourgame
のような URL をモジュール名に使用します。実際のところ、自分のプログラムを公開するつもりがないのであれば、 example.com/m
などどんなモジュール名でも問題ありません。モジュール名は後でいつでも変えられます。
Then, run the command to execute an Ebiten example.
次に、 Ebiten のサンプルを実行します。
go get github.com/hajimehoshi/ebiten/v2
go run -tags=example github.com/hajimehoshi/ebiten/v2/examples/rotate
go get
retrieves the code of Ebiten. go run
compiles Go files and runs it immediately after the compilation. As the first retrieving the code and 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.
go get
は Ebiten のコードを取得します。 go run
は Go ファイルをコンパイルし、即座に実行します。最初のコード取得とコンパイルは少々時間がかかるかもしれないため、しばらくお待ち下さい。必要ならば -x
をつけることで、コンパイル処理中に何が行われているのかを見ることができます。
Note that -tags=example
is needed to execute the examples as the Ebiten example packages require the build tag.
-tags=example
は Ebiten のサンプルを実行するために必要です。 Ebiten サンプルのパッケージがビルドタグを必要とするためです。
If you see this window with a rotating Gophers image, congratulations!
You have sucessfully installed Ebiten!
回転する Gopher の絵がウィンドウ上に表示されたならば、おめでとうございます! Ebiten のインストールに成功しました。