Skip Menu |
 

This queue is for tickets about the Net-Pcap CPAN distribution.

Report information
The Basics
Id: 53292
Status: patched
Worked: 3 hours (180 min)
Priority: 0/
Queue: Net-Pcap

People
Owner: Nobody in particular
Requestors: corion [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.16
Fixed in: (no value)

Attachments
0001-Add-.gitignore.patch
0002-Add-a-sanity-self-check-for-have_functions.patch
0003-Make-have_functions-work-on-Win32-as-well.patch
0004-Use-the-Windows-name-for-dev-null.patch
0005-On-Win32-avoid-duplicate-HAVE_REMOVE-compilation-for.patch



Subject: Net::Pcap 0.16 doesn't build on Win32 with libpcap 1.0
Hi,

I'm trying to build Net::Pcap on Win32 with Strawberry Perl 5.10 and dmake, but it fails for me like the attached session. There only is one pcap.h on my machine, the one that belongs to the (one) installed Pcap library. I've copied the include and lib files into C:\Strawberry\c\include resp. C:\Strawberry\c\lib, where they get picked up.

I don't know how to proceed here, as this doesn't look like the "usual" Win32 failures. Could it be that Net::Pcap has a problem with current versions of libpcap?

-max

C:\strawberry\cpan\build\Net-Pcap-0.16-UsJ4ct>padre Makefile.PL

C:\strawberry\cpan\build\Net-Pcap-0.16-UsJ4ct>perl Makefile.PL INC=-IC:/Strawberry/C/inc "LIBS=-LC:/Strawberry/C/lib -lwpcap"
socket.h patched... ok
looking for -lwpcap... yes
checking for pcap_lib_version() in -lwpcap... yes
detecting available functions... ok
Writing Makefile for Net::Pcap

C:\strawberry\cpan\build\Net-Pcap-0.16-UsJ4ct>dmake
gcc -c  -IC:/Strawberry/C/inc   -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -D
PERL_MSVCRT_READFIX -s -O2        -DVERSION=\"0.16\"    -DXS_VERSION=\"0.16\"  "-IC:\strawberry\perl\lib\CORE"  -DWINSOCK2_H_REQUEST
ED -DWPCAP -DHAVE_REMOTE -DHAVE_BLANK -DHAVE_PCAP_LIB_VERSION Pcap.c
In file included from Pcap.xs:43:
stubs.inc:85:2: warning: #warning "the function pcap_findalldevs() is not available, but will be emulated"
In file included from Pcap.xs:43:
stubs.inc:91: error: redefinition of `struct pcap_if'
stubs.inc:113:2: warning: #warning "the function pcap_breakloop() is not available"
stubs.inc:127:2: warning: #warning "the function pcap_setnonblock() is not available"
stubs.inc:142:2: warning: #warning "the function pcap_getnonblock() is not available"
stubs.inc:157:2: warning: #warning "the function pcap_dump_file() is not available"
stubs.inc:172:2: warning: #warning "the function pcap_dump_flush() is not available"
stubs.inc:187:2: warning: #warning "the function pcap_list_datalinks() is not available"
stubs.inc:202:2: warning: #warning "the function pcap_set_datalink() is not available"
stubs.inc:217:2: warning: #warning "the function pcap_datalink_name_to_val() is not available"
stubs.inc:232:2: warning: #warning "the function pcap_datalink_val_to_name() is not available"
stubs.inc:247:2: warning: #warning "the function pcap_datalink_val_to_description() is not available"
stubs.inc:262:2: warning: #warning "the function pcap_compile_nopcap() is not available"
stubs.inc:267: error: conflicting types for 'pcap_compile_nopcap'
c:/strawberry//c/bin/../lib/gcc/mingw32/3.4.5/../../../../include/pcap/pcap.h:319: error: previous declaration of 'pcap_compile_nopc
ap' was here
stubs.inc:267: error: conflicting types for 'pcap_compile_nopcap'
c:/strawberry//c/bin/../lib/gcc/mingw32/3.4.5/../../../../include/pcap/pcap.h:319: error: previous declaration of 'pcap_compile_nopc
ap' was here
stubs.inc:277:2: warning: #warning "the function pcap_get_selectable_fd() is not available"
stubs.inc:292:2: warning: #warning "the function pcap_next_ex() is not available"
stubs.inc:307:2: warning: #warning "the function pcap_sendpacket() is not available"
stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr() is not available"
stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is not available"
stubs.inc:352:2: warning: #warning "the function pcap_open() is not available"
stubs.inc:357: error: redefinition of `struct pcap_rmtauth'
stubs.inc:373:2: warning: #warning "the function pcap_setbuff() is not available"
stubs.inc:388:2: warning: #warning "the function pcap_setuserbuffer() is not available"
stubs.inc:403:2: warning: #warning "the function pcap_setmode() is not available"
stubs.inc:418:2: warning: #warning "the function pcap_setmintocopy() is not available"
stubs.inc:433:2: warning: #warning "the function pcap_sendqueue_alloc() is not available"
stubs.inc:438: error: redefinition of `struct pcap_send_queue'
stubs.inc:455:2: warning: #warning "the function pcap_sendqueue_destroy() is not available"
stubs.inc:469:2: warning: #warning "the function pcap_sendqueue_queue() is not available"
stubs.inc:484:2: warning: #warning "the function pcap_sendqueue_transmit() is not available"
stubs.inc:499:2: warning: #warning "the function pcap_event() is not available"
stubs.inc:514:2: warning: #warning "the function pcap_setsampling() is not available"
stubs.inc:519: error: redefinition of `struct pcap_samp'
Pcap.c: In function `XS_Net__Pcap_strerror':
Pcap.c:1572: warning: assignment discards qualifiers from pointer target type
dmake:  Error code 129, while making 'Pcap.o'

C:\strawberry\cpan\build\Net-Pcap-0.16-UsJ4ct>
From: Sagarkha [...] hcl.in
Download (untitled) / with headers
text/plain 163b
I am getting the same warning mesaages...see this perl monk node for more details. http://www.perlmonks.org/?node_id=863878. Do we have a solution for it?
Download (untitled) / with headers
text/plain 231b
The problem was in the function have_function(), which did not work on Win32. The attached patches make Net::Pcap 0.16+ compile and pass most tests against Winpcap 4.1.2 (libpcap 2.4). The meat of the patch is in patch 0003. -max
Subject: 0001-Add-.gitignore.patch
From d940cd604bc37e130a4dbd30a367722c40b73b0b Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Tue, 22 Mar 2011 21:56:19 +0100 Subject: [PATCH 1/5] Add .gitignore --- .gitignore | 19 +++++++++++++++++++ MANIFEST | 1 + 2 files changed, 20 insertions(+), 0 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7cb4276 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +Makefile +Makefile.old +*.tar.gz +*.bak +pm_to_blib +blib/ +Net-Pcap-* +.releaserc +cover_db +Pcap.c +Pcap.def +*.o +const-c.inc +const-xs.inc +funcs.txt +macros.all +Pcap.bs +dll.exp +dll.base \ No newline at end of file diff --git a/MANIFEST b/MANIFEST index c0aaa7a..015cc36 100644 --- a/MANIFEST +++ b/MANIFEST @@ -47,3 +47,4 @@ t/portfs.t t/README t/samples/ping-ietf-20pk-be.dmp t/samples/ping-ietf-20pk-le.dmp +.gitignore \ No newline at end of file -- 1.6.5.1.1367.gcd48
Subject: 0002-Add-a-sanity-self-check-for-have_functions.patch
From 0da347aae6e66e95c7dfa847598798c6de1db292 Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Tue, 22 Mar 2011 21:56:46 +0100 Subject: [PATCH 2/5] Add a sanity self-check for have_functions() --- Makefile.PL | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 26ab13e..b966faa 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -104,6 +104,9 @@ REASON # missing functions with croaking stubs. # We also store the list of available functions in a file for skipping the # corresponding tests. +my $sanity_check = have_functions('pcap_open_live'); +die "Couldn't find pcap_open_live(). Something is very wrong." + unless $sanity_check; my @funcs = have_functions(find_functions()); $options{DEFINE} .= cpp_defines(@funcs); open(FUNCS, '>funcs.txt') or warn "warning: can't write 'funcs.txt': $!\n"; -- 1.6.5.1.1367.gcd48
Subject: 0004-Use-the-Windows-name-for-dev-null.patch
From e1525c5cdae88dbed165394a821aa0e3ff207844 Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Tue, 22 Mar 2011 21:58:10 +0100 Subject: [PATCH 4/5] Use the Windows-name for /dev/null --- Makefile.PL | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index ca76b8e..c8cab5b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -290,7 +290,7 @@ BEGIN { $has_Win32 = !$@; $is_Win32 = ($^O eq 'MSWin32'); if ($is_Win32) { - $DEVNULL = 'DEVNULL'; + $DEVNULL = 'NUL:'; } else { $DEVNULL = eval { File::Spec->devnull }; if ($@) { $DEVNULL = '/dev/null' } -- 1.6.5.1.1367.gcd48
Subject: 0003-Make-have_functions-work-on-Win32-as-well.patch
From b10564cf443e6357c300ca716522e7f88bff7c8a Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Tue, 22 Mar 2011 21:57:16 +0100 Subject: [PATCH 3/5] Make have_functions() work on Win32 as well --- Makefile.PL | 33 ++++++++++++++++++++++++++++----- 1 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index b966faa..ca76b8e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,6 +4,7 @@ use Cwd; use ExtUtils::MakeMaker; eval "use ExtUtils::MakeMaker::Coverage"; use File::Spec; +use File::Basename; my ($DEBUG, %options, $DEVNULL, $is_Win32, $has_Win32); @@ -533,13 +534,35 @@ sub have_functions { my @funcs = (); print "detecting available functions... "; - my @paths = DynaLoader::dl_findfile(qw(-lpcap)); - my $libref = DynaLoader::dl_load_file($paths[0]); - + my @paths = DynaLoader::dl_findfile(split /\s+/, $options{LIBS}); + die "Couldn't find any library file satisfying '$options{LIBS}'" + unless @paths; + my $libfile = $paths[0]; + + # On Win32, we assume that the lib file will not be statically linked + # but will be a thin wrapper for a similarly named .dll file. + # This is not universal but works in many cases + # This assumes that a library -l$foo will map to lib$foo.a + # through DynaLoader. We then try to find and load $foo.dll in $ENV{PATH} + if ($has_Win32) { + (my $dll = basename $libfile) =~ s/\.\w+$//; + $dll =~ s/^lib//; + $dll .= '.dll'; + + ($libfile) = grep { -f } map { File::Spec->catfile($_,$dll) } File::Spec->path; + die "'$dll' not found in PATH" + unless $libfile; + }; + warn "Using '$libfile' as potential symbol candidate"; + + my $libref = DynaLoader::dl_load_file($libfile); + warn "Couldn't load $libfile via DynaLoader ($^E)" + unless $libref; for my $func (@_) { my $symref = DynaLoader::dl_find_symbol($libref, $func); - push @funcs, $func if defined $symref - } + push @funcs, $func if defined $symref; + #print "$func", $symref ? "" : " NOT", " found\n"; + }; print "ok\n"; return @funcs -- 1.6.5.1.1367.gcd48
Subject: 0005-On-Win32-avoid-duplicate-HAVE_REMOVE-compilation-for.patch
From a090a70d3247361c2bdd1303411b8428f7f3eccf Mon Sep 17 00:00:00 2001 From: Max Maischein <corion@corion.net> Date: Tue, 22 Mar 2011 22:11:41 +0100 Subject: [PATCH 5/5] On Win32, avoid duplicate HAVE_REMOVE compilation for stubs --- stubs.inc | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/stubs.inc b/stubs.inc index 2cc292e..8ac5400 100644 --- a/stubs.inc +++ b/stubs.inc @@ -516,10 +516,13 @@ HANDLE pcap_getevent(pcap_t *p) { #ifdef _MSC_VER #pragma message( "Warning: the function pcap_setsampling() is not available" ) #endif + +#ifndef HAVE_REMOTE struct pcap_samp { int method; int value; }; +#endif struct pcap_samp *pcap_setsampling(pcap_t *p); struct pcap_samp *pcap_setsampling(pcap_t *p) { -- 1.6.5.1.1367.gcd48


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.