[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] Compiling a simple code which include libvirt



I am trying to compile this code by two methods but it shows error
1) Without -lvirt option
/tmp/ccHGRn8q.o: In function `main':
ex1.c:(.text+0x15): undefined reference to `virConnectOpen'
ex1.c:(.text+0x57): undefined reference to `virConnectClose'


2) with -lvirt option
/usr/bin/ld: cannot find -lvirt
collect2: ld returned 1 exit status


Someone help me!
/* example ex1.c */
/* compile with: gcc -g -Wall ex1.c -o ex -lvirt */
#include <stdio.h>
#include <stdlib.h>
#include "include/libvirt/libvirt.h"
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;
}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]