Regarding location of Libvirt library

Michal Privoznik mprivozn at redhat.com
Wed Mar 31 15:01:29 UTC 2021


On 3/31/21 7:38 AM, shafnamol N wrote:
> Hi,
> I have installed Libvirt 7.1.0.
> I configured and built libvirt based on instructions from
> https://libvirt.org/compiling.html <https://libvirt.org/compiling.html>.
> Now I developed a client program to create a VM using an XML file.As the 
> API for it is *virDomainCreateXML,* called this API by passing XML file 
> .It shows the following error.
> undefined reference to `virDomainCreateXML'.
> I included the header files containing the said API declaration.But need 
> to include the library also.
> My question is where do the libvirt library located after building it.

Yes, you need to pass -lvirt when linking. The library is installed 
wherever you told it to install. If you ran plain meson with no extra 
arguments, then 'meson install' installs library under /usr/local/lib/ 
or /usr/local/lib64/. So you will need to pass -L/usr/local/lib or 
-L/usr/local/lib64 too to the linker.

But there is this switch -Dsystem=true which tells meson to install into 
system directories:

   meson -Dsystem=true build
   meson install -C build

with this you will not need to pass any extra -L arguments to the linker.

Michal




More information about the libvirt-users mailing list