robotgo
robotgo copied to clipboard
Compiling for Windows (on Linux) emits warnings
Building for Windows 64b
GOOS=windows GOARCH=amd64 go build -o "$APP_PROJECT_BIN_DIR/${APP_PROJECT_NAME}.exe" -ldflags="-s -w" main.go
`
github.com/go-vgo/robotgo
/home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:30:29: undefined: hook.Event /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:31:14: undefined: hook.Start /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:36:7: undefined: hook.End /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:43:24: undefined: hook.Event /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:44:14: undefined: hook.Start /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:60:36: undefined: hook.Event /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:65:69: undefined: hook.Event /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/img.go:92:40: undefined: Bitmap /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/img.go:107:38: undefined: Bitmap /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/img.go:137:20: undefined: Bitmap /home/qs/go/pkg/mod/github.com/go-vgo/[email protected]/hook.go:44:14: too many errors `
go version go1.19.4 linux/amd64
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
Actually, it doesn't work on Linux either.
How did this problem ultimately be solved?
Changed the logic of my app and didn't have to use this module.
Test gcc -v and go env | grep CGO_ENABLED in your enviroment.
I have met the same problems.
Reason:
GCCis not installed- Or
GCChasn't been added to the environment variable - Or
go env CGO_ENABLED=0
The solution is to install gcc and add it to the environment variable and set go env -w CGO_ENABLED=1. Refer to https://github.com/go-vgo/robotgo#requirements
By the way, I encountered another issue with Win+VSCode+Git Bash, where certain methods were showing as non-existent in the editor, while some others existed. The reason was that I added GCC to the PATH in Git Bash but not in the system, which caused gopls to be unable to resolve these methods. Add GCC to the system environment variable resolved the issue.
@wilon I try go env -w CGO_ENABLED=0,But still reporting an error
# github.com/go-vgo/robotgo
../../go/pkg/mod/github.com/go-vgo/[email protected]/img.go:92:40: undefined: Bitmap
../../go/pkg/mod/github.com/go-vgo/[email protected]/img.go:107:38: undefined: Bitmap
../../go/pkg/mod/github.com/go-vgo/[email protected]/img.go:137:20: undefined: Bitmap
../../go/pkg/mod/github.com/go-vgo/[email protected]/screen.go:26:28: undefined: Rect
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:9:2: undefined: Move
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:17:2: undefined: Toggle
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:18:2: undefined: MilliSleep
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:20:2: undefined: MoveSmooth
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:21:2: undefined: Toggle
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:29:9: undefined: MoveSmooth
../../go/pkg/mod/github.com/go-vgo/[email protected]/robotgo_fn_v1.go:29:9: too many errors
go env | grep CGO_ENABLED
CGO_ENABLED="0"
use go env -w CGO_ENABLED=1
# Building target: windows/arm64
• Generating bindings: Done.
• Installing frontend dependencies: Done.
• Compiling frontend: Done.
• Generating application assets: Done.
• Compiling application: # runtime/cgo
gcc_libinit_windows.c:8:10: fatal error: 'windows.h' file not found
Thanks, I solved this problem with the method provided