Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by binarygrrl (Novice)
on Jan 09, 2013 at 15:13 UTC ( #1012508=perlquestion: print w/ replies, xml ) Need Help??
binarygrrl has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to install Net::Pcap on a Windows XP system using Strawberry Perl. I have installed the win pcap developer library, I have directed the command line to the include and library files. the Makefile.pl command executes just fine. But when I try to dmake, dmake test, and dmake install - I get errors and it fails. I've tried using versions 0.04, 0.05, and 0.16. All with the same results. I've used dmake realclean in between trials, still doesn't help. One error is: "C:\WpdPack\Include\remote.txt.h:39:2: error: #error Please do not include this file directly. Just define HAVE_REMOTE and then include pcap.h" Another error is: "dmake: Error code 129, while making Pcap.o" Two other warnings are also present. What can I do? Trying to code a network sniffing program to monitor data transmission. Any help is GREATLY appreciated - this is my third day of trying to find a work around.

Comment on Net::Pcap installation help (and not with the library)
Re: Net::Pcap installation help (and not with the library)
by Anonymous Monk on Jan 09, 2013 at 15:35 UTC
    read the readme/install, tell the Makefile.PL where to find the winpcap libraries
      I fixed that - and it can find them - still doesn't install ??

        Also consider applying the patch from RT #53292, and/or posting more relevant parts of the output of your build process.

        Are you sure you have installed the Developer resources and not just WinPcap? Download the zip from my first link, extract to C:\WpdPack then:

        perl Makefile.PL INC=-IC:/WpdPack/Include "LIBS=-LC:/WpdPack/Lib -lwpc +ap" 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 Writing MYMETA.yml and MYMETA.json
Re: Net::Pcap installation help (and not with the library)
by VinsWorldcom (Priest) on Jan 09, 2013 at 16:14 UTC

    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
      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... :(
      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'.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012508]
Approved by ww
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-09-16 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls