electricbubble / go-toast

cross-platform library for sending desktop notifications
MIT License
24 stars 8 forks source link

Can't build on Linux #1

Open salomeldc opened 2 years ago

salomeldc commented 2 years ago

Hi, I want to build an application on Linux that will be using your package to send notification on Windows. Whn building I have this error :

# github.com/electricbubble/go-toast x86_64-w64-mingw32-gcc: fatal error: cannot execute 'cc1obj': execvp: No such file or directory compilation terminated.

Is it possible to do what I want to do ? If yes, how can I bypass this issue ?

electricbubble commented 2 years ago

Cross compile from Linux to Windows with CGO_ENABLED = 0

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ./main.go
salomeldc commented 2 years ago

Thanks. When compiling on Linux with your version 0.2.0 (as I don't need the Objective C extension), I first have this issue :

/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast_windows.go:46:13: undefined: os.WriteFile
/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast_windows.go:203:11: undefined: os.WriteFile

When replacing os by ioutil, I then have this mistake :

/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast.go:5:31: undefined: notification
/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast.go:11:17: undefined: notification
/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast.go:20:17: undefined: notification
/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast.go:29:17: undefined: notification
/gopath/pkg/mod/github.com/electricbubble/go-toast@v0.2.0/toast.go:39:19: undefined: newNotification

And then :

Unknown field HideWindows in struct literal of type syscall.SysProcAttr

I didn't went further as it seems useless, but do you have any solution?

electricbubble commented 2 years ago
undefined: os.WriteFile

https://github.com/golang/go/blob/89044b6d423a07bea3b6f80210f780e859dd2700/src/io/ioutil/ioutil.go#L40-L47

You should upgrade to Go 1.16 or later.