[libvirt] Problems using libvirt (linking errors)

Hello, I habe a problem using a recent libvirt-Version (0.4.4) (installed from backports.org) in my own programms. I had used an older Version a while ago, but I think something might have changed in the API(?), since the old code has the same problems now. I include the headers #include <libvirt/libvirt.h> #include <libvirt/virterror.h> but when linking, I'll get errors like XSSserver.o: In function `XSSserver::XSSserverinitializeService(void*)': /root/rsplib-2.5.0/rsplib/XSSserver.cc:68: undefined reference to `virInitialize' /root/rsplib-2.5.0/rsplib/XSSserver.cc:72: undefined reference to `virConnectOpen' here is the function: bool XSSserver::XSSserverinitializeService(void* userData) { if ( virInitialize() != 0) { puts("WARNING: vir Initializew failed\n") ; return false; } virCon=virConnectOpen(NULL); if (virCon != NULL ) { return true; } puts("WARNING: Initialisierung misslungen") ; return false; } Any hints what I've done wrong/how to debug that problem? regards Johannes

Hi, I guess You are missing linking libvirt. If not, Please check libvirt library by using nm command. Thanks Atsushi SAKAI johannes@formann.de (Johannes Formann) wrote:
Hello,
I habe a problem using a recent libvirt-Version (0.4.4) (installed from backports.org) in my own programms. I had used an older Version a while ago, but I think something might have changed in the API(?), since the old code has the same problems now.
I include the headers #include <libvirt/libvirt.h> #include <libvirt/virterror.h>
but when linking, I'll get errors like XSSserver.o: In function `XSSserver::XSSserverinitializeService(void*)': /root/rsplib-2.5.0/rsplib/XSSserver.cc:68: undefined reference to `virInitialize' /root/rsplib-2.5.0/rsplib/XSSserver.cc:72: undefined reference to `virConnectOpen'
here is the function: bool XSSserver::XSSserverinitializeService(void* userData) { if ( virInitialize() != 0) { puts("WARNING: vir Initializew failed\n") ; return false; } virCon=virConnectOpen(NULL); if (virCon != NULL ) { return true; } puts("WARNING: Initialisierung misslungen") ; return false; }
Any hints what I've done wrong/how to debug that problem?
regards Johannes
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Atsushi SAKAI <sakaia@jp.fujitsu.com> wrote: Hi,
I guess You are missing linking libvirt.
What do you mean, would it be autmoticaly linked like other librarys in /usr/lib? (sorry, I'm not a c/c++ expert)
If not, Please check libvirt library by using nm command.
# nm /usr/lib/libvirt.so.0.4.4 nm: /usr/lib/libvirt.so.0.4.4: no symbols # nm -D /usr/lib/libvirt.so.0.4.4 <lost of output like..> cxa_finalize U __errno_location U __fprintf_chk U __fxstat64 w __gmon_start__ U __isnan U __memmove_chk U __printf_chk U __snprintf_chk U __sprintf_chk U __strcat_chk U __strcpy_chk U __strdup U __strncat_chk U __strncpy_chk U __strndup U __strtod_internal U __strtol_internal U __strtoll_internal U __strtoul_internal U __strtoull_internal 00010820 T __virAlloc 000107e0 T __virAllocN 00017bc0 T __virBufferAdd 00017880 T __virBufferAddChar 00017c60 T __virBufferContentAndReset 00017550 T __virBufferError 00017ac0 T __virBufferVSprintf 00033890 T __virConfFree 00033b00 T __virConfGetValue 00033c40 T __virConfNew 00034b50 T __virConfReadFile 00034ad0 T __virConfReadMem including 0000f570 T virConnectOpen 0000f300 T virInitialize So the libary itself should be ok, and I have only some stupid errors in the makefile? regards Johannes
Thanks Atsushi SAKAI
johannes@formann.de (Johannes Formann) wrote:
Hello,
I habe a problem using a recent libvirt-Version (0.4.4) (installed from backports.org) in my own programms. I had used an older Version a while ago, but I think something might have changed in the API(?), since the old code has the same problems now.
I include the headers #include <libvirt/libvirt.h> #include <libvirt/virterror.h>
but when linking, I'll get errors like XSSserver.o: In function `XSSserver::XSSserverinitializeService(void*)': /root/rsplib-2.5.0/rsplib/XSSserver.cc:68: undefined reference to `virInitialize' /root/rsplib-2.5.0/rsplib/XSSserver.cc:72: undefined reference to `virConnectOpen'
here is the function: bool XSSserver::XSSserverinitializeService(void* userData) { if ( virInitialize() != 0) { puts("WARNING: vir Initializew failed\n") ; return false; } virCon=virConnectOpen(NULL); if (virCon != NULL ) { return true; } puts("WARNING: Initialisierung misslungen") ; return false; }
Any hints what I've done wrong/how to debug that problem?
regards Johannes
-- Libvir-list mailing list Libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Johannes Formann <johannes@formann.de> wrote:
Atsushi SAKAI <sakaia@jp.fujitsu.com> wrote:
Hi,
I guess You are missing linking libvirt.
What do you mean, would it be autmoticaly linked like other librarys in /usr/lib? (sorry, I'm not a c/c++ expert)
Thanks for the hint, after a bit "googeling" setting LDFLAGS and runnig the ./configure script solved the problem. regards Johannes
participants (2)
-
Atsushi SAKAI
-
Johannes Formann