Subject: | Net::Pcap 0.17 doesn't build on Win32 with WinPcap 4.1.x |
Follow-up to Bug ID: 53292, version 0.17 does not incorporate the provided patches and thus does not build on Windows (specifically attempted on Windows 7 x64, Strawberry Perl 5.16.1). The following patches consolidate the 4 patches from Bug ID: 53292 and provide 2 patches that when applied, allow Net::Pcap 0.17 to successfully build on Windows.
Please see:
http://www.perlmonks.org/?node_id=1030816
for more details.
Subject: | Net-Pcap-0.17_stubs.inc.patch |
--- stubs.inc Sun Oct 15 18:00:58 2006
+++ stubs.inc Fri Apr 26 12:39:47 2013
@@ -516,10 +516,13 @@
#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) {
Subject: | Net-Pcap-0.17_Makefile.PL.patch |
--- Makefile.PL Tue Nov 27 17:06:02 2012
+++ Makefile.PL Fri Apr 26 12:37:35 2013
@@ -4,6 +4,7 @@
use ExtUtils::MakeMaker;
eval "use ExtUtils::MakeMaker::Coverage";
use File::Spec;
+use File::Basename;
my ($DEBUG, %options, $DEVNULL, $is_Win32, $has_Win32);
@@ -105,6 +106,9 @@
# 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";
@@ -292,7 +296,7 @@
$has_Win32 = !$@;
$is_Win32 = ($^O eq 'MSWin32');
if ($is_Win32) {
- $DEVNULL = 'DEVNULL';
+ $DEVNULL = 'NUL:';
} else {
$DEVNULL = eval { File::Spec->devnull };
if ($@) { $DEVNULL = '/dev/null' }
@@ -536,13 +540,35 @@
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