rgbkrk / libvirt-go

[DEPRECATED] Go bindings for libvirt
https://github.com/libvirt/libvirt-go
MIT License
166 stars 50 forks source link

-ldl in #cgo causes linker failures #53

Closed mmlb closed 8 years ago

mmlb commented 8 years ago

When trying to build master in a buildroot/crosstool-ng environment with go1.5 and gcc 4.9.2, we hit on a linker issue.

/builds/MIST-621.1/base/target/lib/librt.so.1: undefined reference to `__shm_directory@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status

I had a PR prepped that added -lrt before the -ldl to all #cgo lines since it seemed that -lrt is added to link stage automatically. But the missing symbol is unaccounted for because librt would have gotten it from libpthread through libdl, but since you already specified libdl the linker did not try to scan again. phew.

So that pr worked but it seemed strange that it was even necessary. We removed -ldl and libvirt linked correctly. Now, this is with libvirt 1.2.9 and newer go and possibly gcc that you use in the vagrantfile so I tried to verify but it seems that chef/fedora19 is no longer around and I can't test in your vagrant env. Can you verify that -ldl is necessary?

alexzorin commented 8 years ago

Thanks for reporting. Bummer that the Vagrant box disappeared.

I tried both Go 1.3 and Go 1.5 with just -lvirt and everything seems to link OK. libdl appears in the very first commit of this project so I am not too sure why I did it, possibly it is copy-pasted.

I'll pop this change in master and see how it goes.

mmlb commented 8 years ago

cool :+1: