LoginSignup
21
21

More than 5 years have passed since last update.

Go用のGoogle製のGUIツールキットgxuiのインストール(Windows版)

Last updated at Posted at 2015-03-18

注意

2015/10/28時点で、

Unfortunately due to a shortage of hours in a day, GXUI is no longer maintained.
If you're looking for a GUI library for your next Go project, check out these alternatives.

とあり、GXUIのメンテナンスは終了しました。
以下の記事は、残しますが別のライブラリに移るべきという状況です。

以下、本文です。


GoogleがGo用の新しいGUIライブラリのgxui をリリースしました。
http://qiita.com/shibukawa/items/549bc3af2232099112ac

ということで、自分もWindowsで試してみました。
結論から言うと、3回目のトライのやり方で簡単にンストールすることが可能です。
go getのみでインストールできるので良いですね。

環境

Window8.1 64bit
go version go1.4.2 windows/amd64

最初のトライ

最初は、@shibukawa さんが書かれているMac用の手順を見つつインストールしましたが、それなりに面倒でした。
(当時は面倒だったという意味です)

http://sourceforge.net/projects/glew/files/glew/snapshots/ から glew-1.12.0-win32.zip をダウンロード。
Windows用はBuild済みのため、includeとbin以下のみ使います。

以下の順にgo get。
go-gl-legacyあたりからinclude pathの変更やLDFLAGSなどが必要でした。

$ go get github.com/google/gxui
$ go get code.google.com/p/freetype-go/freetype/truetype
$ go get github.com/go-gl-legacy/gl
$ go get github.com/go-gl/glfw/v3.1/glfw

とはいえ無事にインストールは完了し、gxuiのサンプルは動作しました。
(2回目のトライのが簡単なので詳細は割愛)

2回目のトライ

この記事を書くにあたり、再度手順の確認を実施しました。
今度は、単純にエラーメッセージに従ってのインストールをしてみました。
gxui/sample/polygon等をgo buildするにあたり、以下のエラーメッセージがでるので順番に対処します。

$ go get github.com/google/gxui
$ cd %GOPATH%\src\github.com\google\gxui\samples\polygon
$ go build
(ここで cannot find package "code.google.com/p/freetype-go/freetype/raster" が出力される)
$ go get code.google.com/p/freetype-go/freetype/raster

$ go build
(ここで ~~略~~が出力される)
$ go get github.com/go-gl/gl/v3.2-core/gl

$ go build
(ここで ~~略~~が出力される)
$ go get github.com/go-gl/glfw/v3.1/glfw

$ go build
(build成功)

C言語まったくわからなくても大丈夫ですね。
実行は以下のようにします。
実行には、SourceCodePro-Regular.ttfが必要なので、適宜DLしておきます。

$ dir
2015/03/18  22:32             2,609 main.go
2015/03/18  22:36        10,180,096 polygon.exe
2015/03/18  22:23           103,820 SourceCodePro-Regular.ttf

$ polygon.exe -data=.

10MB超とそれなりに大きいですが、単体で動くのでいい感じです。

progress_barのサンプルは以下のイメージ。

gxui_progress_bar.png

3回目のトライ

2015/06/16に追加しています。

Win8.1 64bit + go1.4.2 windows/amd64 + gcc 4.8.3 64bit (strawberry perl 5.20.2 64bitに付属)という環境で現時点のインストール方法は以下になります。
試したコマンドは以下で、ある程度環境変数PATHを絞った内容としています。
gccは、c:\strawberry\c\bin以下にあるものを使っています。

$ set GOPATH=c:\new_dir_for_test
$ set PATH=%GOPATH%\bin;%GOROOT%\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Git\cmd;C:\Program Files\Mercurial;c:\Strawberry\c\bin
$ go get -u github.com/google/gxui/...

とても簡単にインストールすることができました。
以下は、file_dlg.exeのDemoとなります。

file_dlg.png

最後に

まだサンプルをBuildしただけなのでよくわかっていませんが、インストールは簡単だ、というのはわかりました。

21
21
7

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
21