[Libvir] [PATCH] A few more Windows / MinGW fixups

A few fairly miscellaneous fixups for Windows (MinGW) which fix shared library builds and fix error handling for sockets. (1) XDR functions on MinGW come from a library called 'libxdr', not 'librpc'. (2) To build a DLL under MinGW we need to pass the -no-undefined flag to the linker. (3) Socket compatibility header file replaces <winsock2.h> inclusion. This just defines a portable 'socket_errno()' function which returns errno in the normal case, or WSAGetLastError() in the Windows case. (4) Use socket_errno() instead of errno in a few cases (but only when the code can be compiled under Windows, ie. only in the remote client case). Example -- a dynamically linked virsh.exe (linked to libvirt-0.dll) accessing a remote libvirtd: $ src/.libs/virsh.exe -c test+tcp://192.168.2.128/default list Id Name State ---------------------------------- 1 test running If you want to compile this under Windows, you will need: (a) MinGW & MSYS (select the "candidate" versions of MinGW tools if you are using Vista or W2K8, since otherwise nothing works because of a known bug). (b) Install gcc 4 experimental package from MinGW site. It's called gcc-sjlj for reasons which escape me. (c) Install GnuTLS binary from http://www.gnu.org/software/gnutls/download.html. I'm using GnuTLS Windows binary 1.6.3 and I had to hand-hack the *.la files in that distribution because they contain incorrect paths. (d) Compile and install latest libxml2 from http://xmlsoft.org/. I'm using 2.6.30. (e) Compile and install my XDR package for Windows (http://www.annexia.org/tmp/xdr-4.0-mingw5.tar.gz) (f) ./configure --without-xen --without-qemu --without-sasl --without-libvirtd (g) make Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Fri, Jan 04, 2008 at 12:57:16PM +0000, Richard W.M. Jones wrote:
A few fairly miscellaneous fixups for Windows (MinGW) which fix shared library builds and fix error handling for sockets.
(1) XDR functions on MinGW come from a library called 'libxdr', not 'librpc'.
(2) To build a DLL under MinGW we need to pass the -no-undefined flag to the linker.
(3) Socket compatibility header file replaces <winsock2.h> inclusion. This just defines a portable 'socket_errno()' function which returns errno in the normal case, or WSAGetLastError() in the Windows case.
(4) Use socket_errno() instead of errno in a few cases (but only when the code can be compiled under Windows, ie. only in the remote client case).
ACK. All looks good to me. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Sat, Jan 05, 2008 at 12:02:49AM +0000, Daniel P. Berrange wrote:
On Fri, Jan 04, 2008 at 12:57:16PM +0000, Richard W.M. Jones wrote:
A few fairly miscellaneous fixups for Windows (MinGW) which fix shared library builds and fix error handling for sockets.
(1) XDR functions on MinGW come from a library called 'libxdr', not 'librpc'.
(2) To build a DLL under MinGW we need to pass the -no-undefined flag to the linker.
(3) Socket compatibility header file replaces <winsock2.h> inclusion. This just defines a portable 'socket_errno()' function which returns errno in the normal case, or WSAGetLastError() in the Windows case.
(4) Use socket_errno() instead of errno in a few cases (but only when the code can be compiled under Windows, ie. only in the remote client case).
ACK. All looks good to me.
Agreed, trying to isolate Windows specifics networking bits in a special header is a good idea +1 Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Sat, Jan 05, 2008 at 12:02:49AM +0000, Daniel P. Berrange wrote:
On Fri, Jan 04, 2008 at 12:57:16PM +0000, Richard W.M. Jones wrote:
A few fairly miscellaneous fixups for Windows (MinGW) which fix shared library builds and fix error handling for sockets.
(1) XDR functions on MinGW come from a library called 'libxdr', not 'librpc'.
(2) To build a DLL under MinGW we need to pass the -no-undefined flag to the linker.
(3) Socket compatibility header file replaces <winsock2.h> inclusion. This just defines a portable 'socket_errno()' function which returns errno in the normal case, or WSAGetLastError() in the Windows case.
(4) Use socket_errno() instead of errno in a few cases (but only when the code can be compiled under Windows, ie. only in the remote client case).
ACK. All looks good to me.
Agreed, trying to isolate Windows specifics networking bits in a special header is a good idea +1 Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Committed. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903
participants (3)
-
Daniel P. Berrange
-
Daniel Veillard
-
Richard W.M. Jones