sqweek / dialog

Simple cross-platform dialog API for go-lang
ISC License
516 stars 78 forks source link

Crossplatform build for MacOS #47

Closed taglme closed 4 years ago

taglme commented 4 years ago

Hi! Our project uses this great package. We try to make cross compilation in docker image for darwin paltform. We use docker image for golang cross platform building https://hub.docker.com/r/dockercore/golang-cross/ And for darwin platform get this error # github.com/sqweek/dialog/cocoa In file included from go/pkg/mod/github.com/sqweek/dialog@v0.0.0-20200304031853-0dcd55bfe06a/cocoa/dlg_darwin.go:6: ./dlg.h:1:10: fatal error: 'objc/NSObjcRuntime.h' file not found #include <objc/NSObjcRuntime.h> We checked that this file is existed under SDK folder /osxcross/target/SDK/MacOSX10.10.sdk/usr/include/objc

Builds for windows and linux platform passed successfully at the same image. Is it possible to get some hints how to check what is wrong with build setup. Thanks a lot!

sqweek commented 4 years ago

I've never used docker myself so can't make any specific suggestions, but based on your description it sounds like the C compiler doesn't know where to look for the header. In native OSX I guess the SDK is in the default search path.

It's also possible you could drop that #include or move it to the .m file, I don't think it strictly needs to be in the .h especially from the go side.

taglme commented 4 years ago

I found that there is a typo in dlg.h file: NSObjcRuntime.h should be NSObjCRuntime.h Could you please check it? It is not big deal when build is made on macOS as it is case insensitive os. Linux is case sensitive and it throws an error that file not found. So when I change to `

include <objc/NSObjCRuntime.h>`

build is successfull

sqweek commented 4 years ago

Oh right that would explain it. Thanks for the fix!