Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Net::Pcap installation help (and not with the library)

by VinsWorldcom (Priest)
on Jan 09, 2013 at 16:14 UTC ( #1012521=note: print w/ replies, xml ) Need Help??


in reply to Net::Pcap installation help (and not with the library)

UPDATE: This works for Net::Pcap 0.16 on MSWin32. If using Net::Pcap 0.17, see Re^5: Net::Pcap installation help (and not with the library)


There are bugs in the Net::Pcap code that have not been patched that affect Windows installations. You can see this by looking at the bug report here https://rt.cpan.org/Public/Bug/Display.html?id=53292. Our own Corion fixed it and provided patches.

I've gotten Net::Pcap to build successfully on Windows XP / Strawberry 5.10, 5.12, 5.14 and also Windows 7 x64 / Strawberry 5.14, 5.16. I've used the following process:


References

https://rt.cpan.org/Public/Bug/Display.html?id=53292
http://perlmonks.org/?node_id=894897
http://perlmonks.org/?node_id=896237

--Net::Pcap

  1. Get Net::Pcap from CPAN - download .tar.gz file, not with CPAN client.
  2. Get patches: https://rt.cpan.org/Ticket/Display.html?id=53292
  3. Edit patch files to remove the email headers.
  4. Copy *.patch files into the Net-Pcap directory.
  5. Apply patch files in order (0002, 0003, 0004, 0005) with:
      patch -p1 < FILENAME.patch
    

    NOTE: May have to 'unix2dos' the patch files if they don't work!

--WinPcap

  1. Make sure WinPcap is installed - if not, install it
  2. Unzip WinPcap Developers Pack http://www.winpcap.org/devel.htm in same parent directory Net::Pcap was unzipped in, e.g.,:
      tmp\Net-Pcap-0.16\..
      tmp\WpdPack\..
    
  3. IF on x64 platform, check on the existence of the x64 libraries:
      dir WpdPack\lib\x64\*.a
    
  4. They may not exist. If not, built them:
      pexports \Windows\system32\wpcap.dll > wpcap.def
      dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libwpcap.a --input-def wpcap.def
    
      pexports \Windows\system32\Packet.dll > Packet.def
      dlltool --as-flags=--64 -m i386:x86-64 -k --output-lib libpacket.a --input-def Packet.def
    
      move libwpcap.a WpdPack\lib\x64
      move libpacket.a WpdPack\lib\x64
    
  5. Start the build process:
    perl Makefile.PL INC=-IC:/Users/VinsWorldcom/tmp/WpdPack/Include "LI +BS=-LC:/Users/VinsWorldcom/tmp/WpdPack/Lib/x64 -lwpcap" dmake dmake test

Test by creating test.pl:

use Net::Pcap qw(:functions); @devs = pcap_findalldevs(\%devinfo, \$err); for my $dev (@devs) { print "$dev : $devinfo{$dev}\n" }

Run:

perl -Mblib test.pl

If successful output of adapters, install with:

dmake install


Comment on Re: Net::Pcap installation help (and not with the library)
Select or Download Code
Re^2: Net::Pcap installation help (and not with the library)
by binarygrrl (Novice) on Jan 10, 2013 at 14:10 UTC
    Thank you for the walk-thru :) Patches 0002, and 0003 worked fine - but 0004 and 0005 get stuck. (Error Msgs for both) "Assertion failed: hunk, file .\src\patch\2.5.9\patch-2.5.9-src\patch.c, line 354 This application has requested runtime to terminate it in an unusual way. Please contact the application's support team for more information." How does one, unix2dos?

      "How does one, unix2dos?"

      See Unix2dos for info, and a link to download an executable (note others may exist).

      If you don't have a 'unix2dos' executable for Windows, you can just use Perl:

      perl -pi.bak -e "s/\r/\r\n/" 0004_PATCH_FILE_NAME_HERE
      So I figured out unix2dos, patches went through - still no luck... :(
        After using the unix2dos both machines applied patches (although no response with patches 0002 & 0003 just moved on to a new command line with no errors). On the desktop the cmd perl Makefile.pl executes correctly with all libraries, but still doesn't dmake. The laptop sees a library, then gives me: "Note <probably harmless>: No library found for -lkernel32" and proceeds to list another 18 libraries it can't find I installed winpcap, I unzipped the developer library into C:\WpdPack, I used the command line to tell it where it is - still no luck.... What am I missing here?
        - ERRORS AFTER PATCHING ON DESKTOP WHEN MAKING -
        C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16>dmake cp Pcap.pm blib\lib\Net\Pcap.pm C:\strawberry\perl\bin\perl.exe C:\strawberry\perl\lib\ExtUtils\xsubpp + -typemap C:\strawberry\perl\lib\ExtUtils\ typemap -typemap typemap Pcap.xs > Pcap.xsc && C:\strawberry\perl\bin +\perl.exe -MExtUtils::Command -e mv -- Pcap .xsc Pcap.c gcc -c -IC:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Inclu +de -s -O2 -DWIN32 -DPERL_TEXTMODE_SC RIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing + -mms-bitfields -s -O2 -DVERSION=\"0.1 6\" -DXS_VERSION=\"0.16\" "-IC:\strawberry\perl\lib\CORE" -DWINS +OCK2_H_REQUESTED -DWPCAP -DHAVE_REMOTE -DHA VE_BLANK -DHAVE_PCAP_LIB_VERSION Pcap.c In file included from Pcap.xs:43:0: stubs.inc:85:2: warning: #warning "the function pcap_findalldevs() is +not available, but will be emulated" [-Wcpp ] stubs.inc:91:8: error: redefinition of 'struct pcap_if' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/pcap/pc +ap.h:89:16: note: originally defined here stubs.inc:113:2: warning: #warning "the function pcap_breakloop() is n +ot available" [-Wcpp] stubs.inc:127:2: warning: #warning "the function pcap_setnonblock() is + not available" [-Wcpp] stubs.inc:142:2: warning: #warning "the function pcap_getnonblock() is + not available" [-Wcpp] stubs.inc:157:2: warning: #warning "the function pcap_dump_file() is n +ot available" [-Wcpp] stubs.inc:172:2: warning: #warning "the function pcap_dump_flush() is +not available" [-Wcpp] stubs.inc:187:2: warning: #warning "the function pcap_list_datalinks() + is not available" [-Wcpp] stubs.inc:202:2: warning: #warning "the function pcap_set_datalink() i +s not available" [-Wcpp] stubs.inc:217:2: warning: #warning "the function pcap_datalink_name_to +_val() is not available" [-Wcpp] stubs.inc:232:2: warning: #warning "the function pcap_datalink_val_to_ +name() is not available" [-Wcpp] stubs.inc:247:2: warning: #warning "the function pcap_datalink_val_to_ +description() is not available" [-Wcpp] stubs.inc:262:2: warning: #warning "the function pcap_compile_nopcap() + is not available" [-Wcpp] stubs.inc:267:5: error: conflicting types for 'pcap_compile_nopcap' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/pcap/pc +ap.h:318:5: note: previous declaration of ' pcap_compile_nopcap' was here stubs.inc:268:5: error: conflicting types for 'pcap_compile_nopcap' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/pcap/pc +ap.h:318:5: note: previous declaration of ' pcap_compile_nopcap' was here stubs.inc:277:2: warning: #warning "the function pcap_get_selectable_f +d() is not available" [-Wcpp] stubs.inc:292:2: warning: #warning "the function pcap_next_ex() is not + available" [-Wcpp] stubs.inc:307:2: warning: #warning "the function pcap_sendpacket() is +not available" [-Wcpp] stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr() i +s not available" [-Wcpp] stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is + not available" [-Wcpp] stubs.inc:352:2: warning: #warning "the function pcap_open() is not av +ailable" [-Wcpp] stubs.inc:357:8: error: redefinition of 'struct pcap_rmtauth' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/remote- +ext.h:338:8: note: originally defined here stubs.inc:363:10: error: conflicting types for 'pcap_open' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/remote- +ext.h:417:9: note: previous declaration of 'pcap_open' was here stubs.inc:364:10: error: conflicting types for 'pcap_open' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/remote- +ext.h:417:9: note: previous declaration of 'pcap_open' was here stubs.inc:373:2: warning: #warning "the function pcap_setbuff() is not + available" [-Wcpp] stubs.inc:388:2: warning: #warning "the function pcap_setuserbuffer() +is not available" [-Wcpp] stubs.inc:403:2: warning: #warning "the function pcap_setmode() is not + available" [-Wcpp] stubs.inc:418:2: warning: #warning "the function pcap_setmintocopy() i +s not available" [-Wcpp] stubs.inc:433:2: warning: #warning "the function pcap_sendqueue_alloc( +) is not available" [-Wcpp] stubs.inc:438:8: error: redefinition of 'struct pcap_send_queue' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:46:8: note: originally defined here stubs.inc:444:32: error: conflicting types for 'pcap_send_queue' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:53:32: note: previous declarati on of 'pcap_send_queue' was here stubs.inc:446:19: error: conflicting types for 'pcap_sendqueue_alloc' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:85:18: note: previous declarati on of 'pcap_sendqueue_alloc' was here stubs.inc:447:19: error: conflicting types for 'pcap_sendqueue_alloc' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:85:18: note: previous declarati on of 'pcap_sendqueue_alloc' was here stubs.inc:455:2: warning: #warning "the function pcap_sendqueue_destro +y() is not available" [-Wcpp] stubs.inc:460:6: error: conflicting types for 'pcap_sendqueue_destroy' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:87:6: note: previous declaratio n of 'pcap_sendqueue_destroy' was here stubs.inc:461:6: error: conflicting types for 'pcap_sendqueue_destroy' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:87:6: note: previous declaratio n of 'pcap_sendqueue_destroy' was here stubs.inc:469:2: warning: #warning "the function pcap_sendqueue_queue( +) is not available" [-Wcpp] stubs.inc:474:5: error: conflicting types for 'pcap_sendqueue_queue' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:89:5: note: previous declaratio n of 'pcap_sendqueue_queue' was here stubs.inc:475:5: error: conflicting types for 'pcap_sendqueue_queue' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:89:5: note: previous declaratio n of 'pcap_sendqueue_queue' was here stubs.inc:484:2: warning: #warning "the function pcap_sendqueue_transm +it() is not available" [-Wcpp] stubs.inc:489:7: error: conflicting types for 'pcap_sendqueue_transmit +' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:91:7: note: previous declaratio n of 'pcap_sendqueue_transmit' was here stubs.inc:490:7: error: conflicting types for 'pcap_sendqueue_transmit +' C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16\WpdPack\Include/Win32-E +xtensions.h:91:7: note: previous declaratio n of 'pcap_sendqueue_transmit' was here stubs.inc:499:2: warning: #warning "the function pcap_event() is not a +vailable" [-Wcpp] stubs.inc:514:2: warning: #warning "the function pcap_setsampling() is + not available" [-Wcpp] Pcap.c: In function 'XS_Net__Pcap_strerror': Pcap.c:1603:9: warning: assignment discards 'const' qualifier from poi +nter target type [enabled by default] dmake: Error code 129, while making 'Pcap.o'
        -ERRORS ON LAPTOP WHEN TRYING TO MAKEFILE.PL-
        C:\Perl\Net-Pcap-0.16>perl Makefile.PL INC=-IC:\WpdPack\Include "LIBS= +-LC:\WpdPa ck\Lib -lwpcap" Set up gcc environment - gcc.exe (gcc-4.6.3 release with patches [buil +d 20121012 by perlmingw.sf.net]) 4.6.3 Unable to patch socket.h looking for -lwpcap... yes checking for pcap_lib_version() in -lwpcap... yes detecting available functions... ok Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lkernel32 Note (probably harmless): No library found for -luser32 Note (probably harmless): No library found for -lgdi32 Note (probably harmless): No library found for -lwinspool Note (probably harmless): No library found for -lcomdlg32 Note (probably harmless): No library found for -ladvapi32 Note (probably harmless): No library found for -lshell32 Note (probably harmless): No library found for -lole32 Note (probably harmless): No library found for -loleaut32 Note (probably harmless): No library found for -lnetapi32 Note (probably harmless): No library found for -luuid Note (probably harmless): No library found for -lws2_32 Note (probably harmless): No library found for -lmpr Note (probably harmless): No library found for -lwinmm Note (probably harmless): No library found for -lversion Note (probably harmless): No library found for -lodbc32 Note (probably harmless): No library found for -lodbccp32 Note (probably harmless): No library found for -lcomctl32 Note (probably harmless): No library found for -lmsvcrt Writing Makefile for Net::Pcap Writing MYMETA.yml and MYMETA.json

        With the same developer library on both machines - with the desktop I get:

        C:\Perl\Everything.PERL\Packages\Net-Pcap-0.16>perl Makefile.PL INC=-I +C:\Perl\Everything.PERL\Packages\Net-Pcap-0 .16\WpdPack\Include "LIBS=-LC:\Perl\Everything.PERL\Packages\Net-Pcap- +0.16\WpdPack\Lib -lwpcap" socket.h patched... ok looking for -lwpcap... yes checking for pcap_lib_version() in -lwpcap... yes detecting available functions... ok Checking if your kit is complete... Looks good Writing Makefile for Net::Pcap Writing MYMETA.yml and MYMETA.json

        For the perl Makefile.pl command... But the laptop cannot find the same libraries...

Re^2: Net::Pcap installation help (and not with the library)
by taapm (Initiate) on Apr 25, 2013 at 05:25 UTC
    Hi, I'm getting an error at step 5 doing 'dmake test'.

    The x64 libraries did not exist so I did have to do step 4.

    First, my setup:

    Win 7 64bit

    Strawberry Perl v5.16.3 built for MSWin32-x64-multi-thread installed at D:\strawberry

    Net-Pcap-0.17

    WinPcap v4.1.3

    WpdPack v4.1.2

    Patches 2-5 were applied.

    'perl -V:cc' gives: cc='gcc';

    'perl -V:make' gives: make='dmake';

    Windows PATH:

    PATH=C:\Program Files\ImageMagick-6.8.0-Q16;C:\Program Files (x86)\AMD + APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Windows\sys +tem32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\Windows +PowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core +-Static;c:\program files\oracle\virtualbox;c:\utils;D:\strawberry\c\b +in;D:\strawberry\perl\site\bin;D:\strawberry\perl\bin
    and the results for 'dmake test':
    D:\strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib\lib', 'blib\arch')" t/*.t # Testing Net::Pcap 0.17 (WinPcap version 4.1.3 (packet.dll version 4. +1.0.2980), based on libpcap version 1.0 branch 1_0_rel0b (20091008)) +under Perl 5.016003 t/00-load.t ................ ok t/01-api.t ................. ok t/02-lookup.t .............. ok t/03-openlive.t ............ skipped: must be run as root t/04-loop.t ................ skipped: must be run as root t/05-dump.t ................ skipped: must be run as root t/06-offline.t ............. skipped: must be run as root t/07-stats.t ............... skipped: must be run as root t/08-filter.t .............. ok t/09-error.t ............... ok t/10-fileno.t .............. ok t/11-snapshot.t ............ skipped: must be run as root t/12-next.t ................ skipped: pcap_next() behaves too strangel +y for being tested on random machines t/13-dispatch.t ............ skipped: must be run as root t/14-datalink.t ............ ok # This platform has been detected as a little endian architecture t/15-is_swapped.t .......... ok t/16-setnonblock.t ......... ok # WinPcap version 4.1.3 (packet.dll version 4.1.0.2980), based on libp +cap version 1.0 branch 1_0_rel0b (20091008) t/17-lib_version.t ......... ok t/18-open_dead.t ........... ok t/19-breakloop.t ........... skipped: must be run as root t/20-constants.t ........... ok t/21-next_ex.t ............. skipped: slowness and random failures... +testing pcap_next_ex() is a PITA # Failed test 'calling setbuff() with no argument' # at t/22-open.t line 46. # expecting: /^arg1 not a reference/ # found: p is not of type pcap_tPtr at t/22-open.t line 45. # Failed test 'calling userbuffer() with no argument' # at t/22-open.t line 52. # expecting: /^Usage: Net::Pcap::setbuff\(p, size\)/ # found: userbuffer is not a valid pcap macro at t/22-open.t line 51. # Failed test 'calling userbuffer() with no argument' # at t/22-open.t line 57. # expecting: /^arg1 not a reference/ # found: userbuffer is not a valid pcap macro at t/22-open.t line 56. # Failed test 'calling setmode() with no argument' # at t/22-open.t line 68. # expecting: /^arg1 not a reference/ # found: p is not of type pcap_tPtr at t/22-open.t line 67. # Failed test 'calling setmintocopy() with no argument' # at t/22-open.t line 79. # expecting: /^arg1 not a reference/ # found: p is not of type pcap_tPtr at t/22-open.t line 78. # Looks like you failed 5 tests of 24. t/22-open.t ................ Dubious, test returned 5 (wstat 1280, 0x500) Failed 5/24 subtests (less 13 skipped subtests: 6 okay) # Failed test 'calling createsrcstr() with incorrect argument type f +or arg6' # at t/23-srcstr.t line 33. # expecting: /^arg6 not a hash ref/ # found: arg6 not a reference at t/23-srcstr.t line 32. # Failed test 'createsrcstr() ' # at t/23-srcstr.t line 70. # got: 'Undefined subroutine &main::createsrcstr called at t/ +23-srcstr.t line 69. # ' # expected: '' # Failed test ' - should return zero: ' # at t/23-srcstr.t line 71. # got: undef # expected: '0' # Failed test ' - checking created source string' # at t/23-srcstr.t line 72. # got: '' # expected: 'rpcap://fangorn:12345/eth0' # Failed test 'parsesrcstr() ' # at t/23-srcstr.t line 76. # got: 'Undefined subroutine &main::parsesrcstr called at t/2 +3-srcstr.t line 75. # ' # expected: '' # Failed test ' - should return zero: ' # at t/23-srcstr.t line 77. # got: undef # expected: '0' # Failed test ' - checking parsed type' # at t/23-srcstr.t line 78. # got: '' # expected: 'rpcap' # Failed test ' - checking parsed host' # at t/23-srcstr.t line 79. # got: '' # expected: 'fangorn' # Failed test ' - checking parsed port' # at t/23-srcstr.t line 80. # got: '' # expected: '12345' # Failed test ' - checking parsed name' # at t/23-srcstr.t line 81. # got: '' # expected: 'eth0' # Looks like you failed 10 tests of 18. t/23-srcstr.t .............. Dubious, test returned 10 (wstat 2560, 0xa00) Failed 10/18 subtests t/50-poe-component-pcap.t .. skipped: POE is not available t/distchk.t ................ skipped: Test::Distribution required for +checking distribution t/pod.t .................... skipped: Test::Pod 1.14 required for test +ing POD t/podcover.t ............... skipped: Currently not working for Net::P +cap t/podspell.t ............... skipped: Pod spelling: for maintainer onl +y t/portfs.t ................. skipped: Only for the module maintainer Test Summary Report ------------------- t/10-fileno.t (Wstat: 0 Tests: 21 Failed: 0) TODO passed: 19 t/22-open.t (Wstat: 1280 Tests: 24 Failed: 5) Failed tests: 5-7, 9, 11 Non-zero exit status: 5 t/23-srcstr.t (Wstat: 2560 Tests: 18 Failed: 10) Failed tests: 3, 10-18 Non-zero exit status: 10 Files=30, Tests=521, 5 wallclock secs ( 0.14 usr + 0.03 sys = 0.17 +CPU) Result: FAIL Failed 2/30 test programs. 15/521 subtests failed. dmake: Error code 255, while making 'test_dynamic'

      You will get some test failures - I don't remember quite that many. But proceed with the process and create and run the test script in the install directory. Run it with 'perl -Mblib test.pl' from the install directory. If that runs fine, then do the 'dmake install'.

        Thanks for the prompt reply. Here's what happens when I try to run the test script:
        D:\strawberry\Net-Pcap-0.17>perl -Mblib test.pl Undefined subroutine &main::pcap_findalldevs called at test.pl line 3

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-04-20 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls