[libvirt] Fwd: Compiling a simple code which include libvirt

Rahul Bansal gtg.bansal at gmail.com
Mon Sep 3 12:39:29 UTC 2012


I ran 'sudo make install' in /path/to/libvirt. But same error is coming.
Maybe following will be helpful:
-> I extracted the libvirt.0.10.1 in ~/Downloads
-> And I am running the code in ~/Downloads/libvirt-0.10.1
-> I ran 'sudo make install' in the above directory.



On 2 September 2012 16:24, Michal Privoznik <mprivozn at redhat.com> wrote:

> On 02.09.2012 09:53, Rahul Bansal wrote:
> > /* example ex1.c */
> > /* compile with: gcc -g -Wall ex1.c -o ex -lvirt */
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include "include/libvirt/libvirt.h"
>
> since you are including this path assume you use
> -I/path/to/libvirt/source and don't have libvirt installed in your
> system. Hence you need to provide linker the path where it will find the
> library:
> gcc -I/path/to/libvirt -L/path/to/libvirt/src -lvirt ex1.c -o ex1
>
> or just install libvirt ('sudo make install' in /path/to/libvirt) and
> then you can drop both -I and -L arguments.
>
> > int main(int argc, char *argv[])
> > {
> > virConnectPtr conn;
> > conn = virConnectOpen("qemu:///system");
> > if (conn == NULL) {
> > fprintf(stderr, "Failed to open connection to qemu:///system\n");
> > return 1;
> > }
> > virConnectClose(conn);
> > return 0;
> > }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120903/53b9f335/attachment-0001.htm>


More information about the libvir-list mailing list