go-gtk icon indicating copy to clipboard operation
go-gtk copied to clipboard

Compiling for Windows on Mac

Open rentziass opened this issue 7 years ago • 6 comments

Hi, probable dumb question incoming, but I'm quite new to Go and totally new to GUI stuff: Is it possible to compile for Windows from macOS? Everything is working fine as long as I try to compile the examples for Mac, but when trying to run

GOOS=windows GOARCH=386 go build

I keep getting this output

../../gtk/gtk.go:19:2: no buildable Go source files in /Users/francescorenzi/development/go/src/github.com/mattn/go-gtk/gdk
demo.go:5:2: no buildable Go source files in /Users/francescorenzi/development/go/src/github.com/mattn/go-gtk/gdkpixbuf
demo.go:6:2: no buildable Go source files in /Users/francescorenzi/development/go/src/github.com/mattn/go-gtk/glib
../../gtk/gtk.go:22:2: no buildable Go source files in /Users/francescorenzi/development/go/src/github.com/mattn/go-gtk/pango
../../gtk/gtk.go:23:2: no buildable Go source files in /Users/francescorenzi/development/go/src/github.com/mattn/go-pointer

To me the chances are I can't do this on my Mac machine or am I missing something really dumb? I tend to the second alternative. By the way the example I'm trying to compile is the demo one.

rentziass avatar Apr 03 '17 15:04 rentziass

You need to install cross C-compiler for Windows.

mattn avatar Apr 04 '17 00:04 mattn

Can you be more specific @mattn? I've successfully built (and distributed) other golang Windows executables from my Mac.

barrettclark avatar May 23 '17 17:05 barrettclark

The same issue: $ GOOS=windows GOARCH=386 go build ../../gtk/gtk.go:19:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-gtk/gdk listview.go:7:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-gtk/gdkpixbuf ../../gtk/gtk.go:21:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-gtk/gio listview.go:8:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-gtk/glib ../../gtk/gtk.go:23:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-gtk/pango ../../gtk/gtk.go:24:2: build constraints exclude all Go files in /home/alex/go/src/github.com/mattn/go-pointer

alex73 avatar Jun 13 '18 08:06 alex73

As I mentioned in above, you MUST use cross C-compiler not host compiler.

mattn avatar Jun 13 '18 08:06 mattn

Can you give an example? Thanks.

thanhps42 avatar Jun 13 '18 08:06 thanhps42

This entry is written not for go-gtk. But might be helpful.

http://www.limitlessfx.com/cross-compile-golang-app-for-windows-from-linux.html

mattn avatar Jun 13 '18 09:06 mattn