Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of somian (5953)

Thursday November 10, 2005
02:27 AM

A tough critter: Net::Pcap on cygwin

[ #27529 ]

A fellow Perler asked me recently if I had ever installed the module Net::Pcap on a cygwinperl system. I had not and decided to look into what might might be going wrong for her.

As an interface to the external pcap library (written in C) the module uses XS and requires compilation. It is a fairly complex build and the authors have gone to a lot of trouble to write a very long Makefile.PL with elaborate "detection" routines. It still seems not to work (and as of this writing, no Net::Pcap release has ever passed on the cygwin platform, according to cpan-testers).

After setting up the WinPcap developers' pack and using the location of its lib and include files as arguments to 'perl Makefile.PL' I saw first errors relating to the detection code (which I'll detail later). After adjusting code in the Makefile.PL to fix them, I got into the test-compilation phase of the Makefile.PL routines and saw a torrent of C compiler errors and warnings flood the console screen. Those errors are thus (filtered through the following pipeline to make them more readable and succinct)

perl Makefile.PL LIBS="-L$W32LIB -lwpcap" INC=-I$W32INCL 2>&1 | perl -naF: -MCwd=realpath -le 'next unless /error/; $pn=$F[0]; $F[1]=~s{/DOCUME~1/SORENS~1/MYDOCU~1/}{/};print "",($pn =~m ? realpath(shift @F):join ":"=>splice(@F,0,2)), join(":"=>"",@F)'

ERRORS

 

C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:271: error: redefinition of `struct timespec'
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:503: error: conflicting types for 'pthread_t'
/usr/include/cygwin/types.h:208: error: previous declaration of 'pthread_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:504: error: conflicting types for 'pthread_attr_t'
/usr/include/cygwin/types.h:212: error: previous declaration of 'pthread_attr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:505: error: conflicting types for 'pthread_once_t'
/usr/include/cygwin/types.h:223: error: previous declaration of 'pthread_once_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:506: error: conflicting types for 'pthread_key_t'
/usr/include/cygwin/types.h:211: error: previous declaration of 'pthread_key_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:507: error: conflicting types for 'pthread_mutex_t'
/usr/include/cygwin/types.h:209: error: previous declaration of 'pthread_mutex_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:508: error: conflicting types for 'pthread_mutexattr_t'
/usr/include/cygwin/types.h:213: error: previous declaration of 'pthread_mutexattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:509: error: conflicting types for 'pthread_cond_t'
/usr/include/cygwin/types.h:215: error: previous declaration of 'pthread_cond_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:510: error: conflicting types for 'pthread_condattr_t'
/usr/include/cygwin/types.h:214: error: previous declaration of 'pthread_condattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:512: error: conflicting types for 'pthread_rwlock_t'
/usr/include/cygwin/types.h:224: error: previous declaration of 'pthread_rwlock_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:513: error: conflicting types for 'pthread_rwlockattr_t'
/usr/include/cygwin/types.h:225: error: previous declaration of 'pthread_rwlockattr_t' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:1082: error: conflicting types for 'pthread_kill'
/usr/include/sys/signal.h:163: error: previous declaration of 'pthread_kill' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/pthread.h:1082: error: conflicting types for 'pthread_kill'
/usr/include/sys/signal.h:163: error: previous declaration of 'pthread_kill' was here
/usr/include/w32api/winsock2.h:101: error: redefinition of `struct timeval'
/usr/include/w32api/winsock2.h:112: error: redefinition of `struct hostent'
/usr/include/w32api/winsock2.h:120: error: redefinition of `struct linger'
/usr/include/w32api/winsock2.h:147: error: redefinition of `struct netent'
/usr/include/w32api/winsock2.h:153: error: redefinition of `struct servent'
/usr/include/w32api/winsock2.h:159: error: redefinition of `struct protoent'
/usr/include/w32api/winsock2.h:215: error: redefinition of `struct in_addr'
/usr/include/w32api/winsock2.h:246: error: redefinition of `struct sockaddr_in'
/usr/include/w32api/winsock2.h:327: error: redefinition of `struct sockaddr'
/usr/include/w32api/winsock2.h:515: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:515: error: conflicting types for 'accept'
/usr/include/sys/socket.h:29: error: previous declaration of 'accept' was here
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:516: error: conflicting types for 'bind'
/usr/include/sys/socket.h:30: error: previous declaration of 'bind' was here
/usr/include/w32api/winsock2.h:518: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:518: error: conflicting types for 'connect'
/usr/include/sys/socket.h:31: error: previous declaration of 'connect' was here
/usr/include/w32api/winsock2.h:520: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:520: error: conflicting types for 'getpeername'
/usr/include/sys/socket.h:32: error: previous declaration of 'getpeername' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:521: error: conflicting types for 'getsockname'
/usr/include/sys/socket.h:33: error: previous declaration of 'getsockname' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:522: error: conflicting types for 'getsockopt'
/usr/include/sys/socket.h:44: error: previous declaration of 'getsockopt' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:523: error: conflicting types for 'inet_addr'
/usr/include/arpa/inet.h:22: error: previous declaration of 'inet_addr' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:524: error: conflicting types for 'inet_ntoa'
/usr/include/arpa/inet.h:28: error: previous declaration of 'inet_ntoa' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:525: error: conflicting types for 'listen'
/usr/include/sys/socket.h:34: error: previous declaration of 'listen' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:526: error: conflicting types for 'recv'
/usr/include/sys/socket.h:35: error: previous declaration of 'recv' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:527: error: conflicting types for 'recvfrom'
/usr/include/sys/socket.h:37: error: previous declaration of 'recvfrom' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:528: error: conflicting types for 'send'
/usr/include/sys/socket.h:39: error: previous declaration of 'send' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:529: error: conflicting types for 'sendto'
/usr/include/sys/socket.h:42: error: previous declaration of 'sendto' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:530: error: conflicting types for 'setsockopt'
/usr/include/sys/socket.h:43: error: previous declaration of 'setsockopt' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:531: error: conflicting types for 'shutdown'
/usr/include/sys/socket.h:45: error: previous declaration of 'shutdown' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:532: error: conflicting types for 'socket'
/usr/include/sys/socket.h:46: error: previous declaration of 'socket' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:533: error: conflicting types for 'gethostbyaddr'
/usr/include/netdb.h:139: error: previous declaration of 'gethostbyaddr' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:534: error: conflicting types for 'gethostbyname'
/usr/include/netdb.h:140: error: previous declaration of 'gethostbyname' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:535: error: conflicting types for 'getservbyport'
/usr/include/netdb.h:149: error: previous declaration of 'getservbyport' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:536: error: conflicting types for 'getservbyname'
/usr/include/netdb.h:148: error: previous declaration of 'getservbyname' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:537: error: conflicting types for 'getprotobynumber'
/usr/include/netdb.h:146: error: previous declaration of 'getprotobynumber' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:538: error: conflicting types for 'getprotobyname'
/usr/include/netdb.h:145: error: previous declaration of 'getprotobyname' was here
/usr/include/w32api/winsock2.h:607: error: parse error before '(' token
/usr/include/w32api/winsock2.h:607: error: parse error before '?' token
/usr/include/w32api/winsock2.h:608: error: parse error before '(' token
/usr/include/w32api/winsock2.h:608: error: parse error before '?' token
/usr/include/w32api/winsock2.h:609: error: parse error before '(' token
/usr/include/w32api/winsock2.h:609: error: parse error before '?' token
/usr/include/w32api/winsock2.h:610: error: parse error before '(' token
/usr/include/w32api/winsock2.h:610: error: parse error before '?' token
/usr/include/w32api/winsock2.h:611: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:611: error: conflicting types for 'select'
/usr/include/sys/select.h:31: error: previous declaration of 'select' was here
/usr/include/w32api/winsock2.h:614: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
/usr/include/w32api/winsock2.h:614: error: conflicting types for 'gethostname'
/usr/include/sys/unistd.h:206: error: previous declaration of 'gethostname' was here
C:/PROJEC~1/CVS_SR~1/WinPcap/include/bittypes.h:71: error: conflicting types for 'int32_t'
/usr/include/stdint.h:20: error: previous declaration of 'int32_t' was here
/usr/include/w32api/ws2tcpip.h:124: error: redefinition of `struct ip_mreq'

That's a pretty discouraging output.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Sorry to have broken Cygwin, but I'm not a Win32/Cygwin programmer and therefore rely on Jean-Louis Morel and generaly on user feedback. I may be the one to blame for this release because I didn't ask Jean-Louis to test it on Cygwin and ActivePerl as I didn't change Win32-related code, and therefore assumed it would work. Can you try version 0.09 or 0.08 and tell me if these work for you? Feel free to fill a bug report in Net::Pcap RT queue [cpan.org].

    Note that the "elaborate detection routines" are unfortunately n

    --
    Close the world. txEn eht nepO
  • Oh, just for the records, the version 0.09 should work on ActivePerl, and you can install the PPM from Randy Kobes' repositories. See http://cpan.uwinnipeg.ca/dist/Net-Pcap [uwinnipeg.ca]

    (I know, it's ActivePerl, not Cygwin; but Cygwin is a little tough to get right, as it partially relies on Win32 to use WinPcap.)

    --
    Close the world. txEn eht nepO
    • Hi, thanks for commenting, Sébastien. No, I am afraid there is nothing sufficiently different in v0.09 that it can work under Cygwin. It doesn't. Two things stand out in the overview of WinPcap and Net::Pcap that I've gotten over the last couple of days. One is that nowhere that I have seen is anyone claiming that WinPcap is software that has been ported to Cygwin. The clear claim is that WinPcap "can be built using cygwin", and I've established, by looking hard at the build infrastructu

      • Ok, I took some time and used a Windows system with a Cygwin to test Net::Pcap myself. I have to admit that it's far from being obvious, but all this comes from the fact that Cygwin pretends to be a Unix system (it internally defines itself as a Unix, offers the Unix API, and defines the preprocessor macro _unix). But in fact, it is really bound by the limitations of the Win32 system on which it runs. It usually works in an quite acceptable manner, but in some corner cases can lead to strange behaviour beca

        --
        Close the world. txEn eht nepO
        • Hello again, Sébastien. No good news, and no bar of chocolate, I'm afraid.

          The technique you cited above is unacceptable to me exactly as given, because the contents of /usr/include are managed by the Cygwin package management system. I under no circumstances will manually copy files into that directory as a matter of programmer / sysadmin discipline. The evils that can stem from that act are manifold, and include being unable to reproduce user errors reported by anyone who trie