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

2012-09-04 Thread Rahul Bansal
On 3 September 2012 20:05, Eric Blake ebl...@redhat.com wrote:

 On 09/03/2012 06:39 AM, Rahul Bansal wrote:

 [Please don't top-post on technical lists.]

  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.

 And what ./configure arguments did you use?  If you didn't supply
 anything in particular, then this installed your copy of libvirt into
 /usr/local/, and depending on your setup, your compiler might not be
 looking into that directory by default.

 --
 Eric Blake   ebl...@redhat.com+1-919-301-3266
 Libvirt virtualization library http://libvirt.org


I have been finally able to compile my libvirt code. Actually I reinstalled
libvirt with some change in autobuild.sh
so that it installed libraries in /usr/local.
Thanks all for your valuable help and suggestions.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

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

2012-09-03 Thread Rahul Bansal
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 mpriv...@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;
  }


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] Compiling a simple code which include libvirt

2012-09-02 Thread Rahul Bansal
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;
}
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list