Hey all,
I suspect I’ve tried to run before I’ve learnt to walk here…
My understanding is that when I build a Go project I get a static binary. I can also set GOOS and GOARCH to build on one OS (e.g. amd64 macOS) and target another (e.g. amd64 Linux).
If I’m using an external dependency like GTK (via github.com/gotk3) and try to build for a non-native OS I seem to get errors when building:
benjaminl@bb-system-1156:wave-stamper %>uname -a
Darwin bb-system-1156 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
benjaminl@bb-system-1156:wave-stamper %>go build
benjaminl@bb-system-1156:wave-stamper %>file wave-stamper
wave-stamper: Mach-O 64-bit executable x86_64
benjaminl@bb-system-1156:wave-stamper %>export GOOS=linux
benjaminl@bb-system-1156:wave-stamper %>go build
# github.com/forquare/wave-stamper/utils
utils/gui.go:11:25: undefined: gtk.Builder
utils/gui.go:11:49: undefined: glib.IObject
benjaminl@bb-system-1156:wave-stamper %>export GOOS=freebsd
benjaminl@bb-system-1156:wave-stamper %>go build
# github.com/gotk3/gotk3/gdk
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/screen_no_x11.go:11:10: undefined: Screen
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/screen_no_x11.go:17:10: undefined: Screen
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/screen_no_x11.go:23:10: undefined: Screen
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/window_no_x11.go:5:10: undefined: Window
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/window_no_x11.go:10:10: undefined: Window
../../pkg/mod/github.com/gotk3/gotk3@v0.4.0/gdk/window_no_x11.go:16:10: undefined: Window
# github.com/forquare/wave-stamper/utils
utils/gui.go:11:25: undefined: gtk.Builder
utils/gui.go:11:49: undefined: glib.IObject
Is there something additional I need to do if I’m using external libraries like this? My naïve assumption was that I’d be able to get a Linux/FreeBSD/Windows binary that included the required bits of GTK I was using…