Open vcraescu opened 6 years ago
Same here, did you find a fix?
same here, couple of reason for this not working, first we need to enable cgo then we need proper darwin libraries, i haven't been able to find a fix myself, but in https://github.com/getlantern/systray/blob/master/systray_nonwindows.go the comments indicate some cflags and ldflags but that gives another error like the following:
[example]$ CC=gcc CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -gccgoflags="-DDARWIN -x objective-c -fobjc-arc" -ldflags="framework Cocoa" main.go
go build: when using gc toolchain, please pass compile flags using -gcflags, and linker flags using -ldflags
# net
/usr/lib/golang/src/net/cgo_bsd.go:15:72: could not determine kind of name for C.AI_MASK
# os/user
/usr/lib/golang/src/os/user/getgrouplist_darwin.go: In function ‘mygetgrouplist’:
/usr/lib/golang/src/os/user/getgrouplist_darwin.go:14:11: warning: implicit declaration of function ‘getgrouplist’; did you mean ‘mygetgrouplist’? [-Wimplicit-function-declaration]
int rv = getgrouplist(user, (int) group, buf, ngroups);
^~~~~~~~~~~~
mygetgrouplist
@oxtoacart Any ideas what is going on here?
Any solution to actually build to Darwin?
Same problem building linux from macOS. Now that I've added GUI code to my app, my CI/CD pipeline can no longer cross compile the binaries. Leaves me in quite a pickle.
If you’re on a macOS it’s less painful to cross-compile manually. Cross-compilation to Windows works OOTB. For Linux, you’d need Docker on a macOS and bit of scripting. For CI/CD pipeline, won’t do it without different platform agent matrix. Maybe it’ll be useful this is how I bootstrap cross-compilation (from macOS host) for a small project with systray.
@koltyakov - Really appreciate that. :) I managed to get the pipeline split into one build for everything else and one for macOS (on a Mac), so I've overcome my pickle.
why was this comment deleted? http://web.archive.org/web/20201221103316/https://github.com/getlantern/systray/issues/34
Not 100% same use-case, but I ran into the same issue when trying to cross compile a darwin amd64 binary on darwin arm64.
I was able to resolve the issue by building it using the following command:
CC=gcc CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -gccgoflags="-DDARWIN -x objective-c -fobjc-arc" -ldflags="framework=Cocoa" .
Not 100% same use-case, but I ran into the same issue when trying to cross compile a darwin amd64 binary on darwin arm64.
I was able to resolve the issue by building it using the following command:
CC=gcc CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -gccgoflags="-DDARWIN -x objective-c -fobjc-arc" -ldflags="framework=Cocoa" .
@nadavami Im trying to cross compile from intel mac to arm64 for m1's and tried some of these flags but I get
GOOS=darwin GOARCH=arm64 go build -a -tags netgo -gccgoflags="-DDARWIN -x objective-c -fobjc-arc" -ldflags "framework=Cocoa -s -w" -o AppleSilicon.app/Contents/MacOS/Bridge
go build: when using gc toolchain, please pass compile flags using -gcflags, and linker flags using -ldflags
# github.com/getlantern/systray
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:78:2: undefined: nativeLoop
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:106:2: undefined: registerSystray
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:111:14: undefined: quit
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:136:2: undefined: addSeparator
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:190:2: undefined: hideMenuItem
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:195:2: undefined: showMenuItem
../../go/pkg/mod/github.com/getlantern/systray@v1.2.1/systray.go:220:2: undefined: addOrUpdateMenuItem
Any ideas? Maybe I have to setup some sort of arm docker container to get this to compile.
Any idea?
Thanks!