Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in libraries when compiling #48

Open
NikolayUvarov opened this issue Sep 7, 2023 · 2 comments
Open

Error in libraries when compiling #48

NikolayUvarov opened this issue Sep 7, 2023 · 2 comments

Comments

@NikolayUvarov
Copy link

using example code from main page ubuntu 22.04/1 LTS
go version go1.21.1 linux/amd64

package main
import (
"runtime"
"time"
"github.com/micmonay/keybd_event"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
panic(err)
}
// For linux, it is very important to wait 2 seconds
if runtime.GOOS == "linux" {
time.Sleep(2 * time.Second)
}
// Select keys to be pressed
kb.SetKeys(keybd_event.VK_A, keybd_event.VK_B)
// Set shift to be pressed
kb.HasSHIFT(true)
// Press the selected keys
err = kb.Launching()
if err != nil {
panic(err)
}
// Or you can use Press and Release
kb.Press()
time.Sleep(10 * time.Millisecond)
kb.Release()
// Here, the program will generate "ABAB" as if they were pressed on the keyboard.
}

$ go build .

github.com/micmonay/keybd_event

../../go/pkg/mod/github.com/micmonay/[email protected]/keybd_event.go:20:9: undefined: initKeyBD

@wangshengzhou
Copy link

I'm getting the same error at compile time
How to fix it

@GPeye
Copy link

GPeye commented Apr 10, 2024

Since it is directly importing C code on linux you need a compiler. Try this
sudo apt install gcc libc6-dev
Then run or build it again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants