libvirt-go 交叉编译在具有 GOOS=Linux 的 macos 上失败

我有一个使用 libvirt-go v7.4.0 的项目。


去.mod:


github.com/libvirt/libvirt-go v7.4.0+incompatible // indirect

它可以在 mac 和 linux 上编译,但是在带有标志的 macos 上交叉编译失败。GOOS=Linux


$ env GOOS=linux go build -o myapp .

# gitlab.mycompany.io/mycompany-platform/myapp/command/agent

command/agent/libvirt_listener.go:11:26: undefined: libvirt.DomainEventType

command/agent/libvirt_listener.go:23:14: undefined: libvirt.Connect

command/agent/libvirt_listener.go:100:9: undefined: libvirt.EventRegisterDefaultImpl

command/agent/libvirt_listener.go:105:15: undefined: libvirt.NewConnect

command/agent/libvirt_listener.go:115:4: undefined: libvirt.EventRunDefaultImpl

command/agent/libvirt_listener.go:121:22: undefined: libvirt.Connect

command/agent/libvirt_listener.go:121:42: undefined: libvirt.Domain

command/agent/libvirt_listener.go:121:65: undefined: libvirt.DomainEventLifecycle

command/agent/libvirt_listener.go:149:63: undefined: libvirt.DomainState

command/agent/libvirt_listener.go:121:22: too many errors


倚天杖
浏览 203回答 1
1回答

茅侃侃

该库包是与本机库的 CGo 绑定。因此,在构建 CGO 时不可能禁用 CGO,反过来也不可能交叉编译,因为这会隐式禁用 CGO。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go