Hello everybody! First, allow me to wish you all a Happy New year! I have a problem with a small app that I wrote in Go and which uses libvirt go bindings. Actually, the problem exists only when I want to compile the code statically. Basically, when CGO_ENABLED=0 is exported, go (running go test, go run, go build) complains: undefined: libvirt.NewConnect When I try to compile the source dynamically (running the same go <command> commands) the app works/checks out as expected and works without any problem. I tried this on: - CentOS 7.6 (go version 1.11.2) - Ubuntu 18.04 LTS (go version 1.10.4) Both systems - as advised on project's github pages/godoc.org - have libvirt-dev package installed. Also, the libvirt module is imported as advised: libvirt "github.com/libvirt/libvirt-go" GOPATH is set to /home/$USER/go I downloaded the package via go get; go get -v -u github.com/libvirt/libvirt-go. Please if somebody encountered this before, could you give me a hint if possible in order to solve this? Thank you very much in advance! Regards, Branimir
Daniel P. Berrangé
2019-Jan-09 10:04 UTC
Re: [libvirt-users] Golang libvirt bindings problem
On Thu, Jan 03, 2019 at 01:37:51AM +0000, Branimir Pejakovic wrote:> Hello everybody! > > First, allow me to wish you all a Happy New year! > > I have a problem with a small app that I wrote in Go and which uses libvirt > go bindings. Actually, the problem exists only when I want to compile the > code statically. Basically, when CGO_ENABLED=0 is exported, go (running go > test, go run, go build) complains: > > undefined: libvirt.NewConnectThe libvirt bindings use CGo, so when you set CGO_ENABLED=0 you break the bindings. You must not set that env variable. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|