Regarding location of Libvirt library

Hi, I have installed Libvirt 7.1.0. I configured and built libvirt based on instructions from 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. Thanks for the help in advance.

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

On Wed, 2021-03-31 at 17:01 +0200, Michal Privoznik wrote:
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.
Note that the recommended way to obtain this information is via pkg-config, using something like $ pkg-config --cflags --libs libvirt If you get an error about libvirt not being found, you probably need to run $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig or something along those lines beforehand. -- Andrea Bolognani / Red Hat / Virtualization
participants (3)
-
Andrea Bolognani
-
Michal Privoznik
-
shafnamol N