how to build libvirt-go-module statically

Daniel P. Berrangé
2023-09-06T08:37:53Z

On Wed, Sep 06, 2023 at 03:25:48PM +0800, Jiatong Shen
wrote:
> Hello community,
>
>    I want to know how to build libvirt-go-module statically? My go version
> is 1.17 and libvirt-go-module version is v1.9007.0. Thank you very much for
> the help.

There is not any way to build fully statically, because libvirt.so itself
does not support static builds. The default build of libvirt Go bindings
will dynamically link to libvirt.so. If you set the 'libvirt_dlopen'
build tag when compiling, then instead of directly dynamically linking,
the libvirt Go binding will dynamically load libvirt.so at runtime.
The latter approach means you DO NOT need libvirt installed in your
development or build environment, but you DO need libvirt.so installed
in your production deployment.

With 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 :|