4

I am trying to install pcapy on a Windows machine. I have already installed WinPcap 4.1.3

I downloaded pcapy 0.10.8 into C:\pcapy-0.10.8

When I try to do the install, the following happens:

C:\pcapy-0.10.8>c:\Python27\python.exe setup.py install
running install
running build
running build_ext
building 'pcapy' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\Bin\amd64\cl.exe /c /nolog o /Ox /MD /W3 /GS- /DNDEBUG -DWIN32=1 -Ic:\devel\oss\wpdpack\Include -Ic:\Python27\include -Ic:\Python27\PC /Tppcapdumper.cc /Fobuild\temp.win-amd64-2.7\Release \pcapdumper.obj
pcapdumper.cc
pcapdumper.cc(12) : fatal error C1083: Cannot open include file: 'pcap.h': No such file or directory
error: command 'cl.exe' failed with exit status 2

I don't know where it's looking for pcap.h. I can confirm that there is no file by that name in the pcapy-0.10.8 directory.

What am I missing? I just now installed WinPcap -- do I need a reboot or something? Thanks!

Edited to add... here is the output from my WinPcap install log:

WinPcap 4.1.0.2980 Installation LOG
-----------------------------------------------------
Debug Information


Operating system detected on registry: 7 - AMD64
True operating system (kernel.dll):    7 - AMD64
npptools.dll present on the system:    false
netnm.inf present on the system:       false
nmnt.sys present on the system:        false

End of log
-----------------------------------------------------

Do the falses there mean that WinPcap did not get installed properly? I was hoping to find pcap.h under my WinPcap directory, but it's not there. I do see where I could add additional include file directories in the setup.py if needed, but I can't find pcap.h anywhere on my machine. Where am I supposed to be getting that from?

PurpleVermont
  • 1,179
  • 4
  • 18
  • 46

4 Answers4

7
C:\pcapy-0.10.8>c:\Python27\python.exe setup.py install

From the text on the CoreLabs site for pcapy, that suggests that you downloaded the source rather than the Win32 binary. Unless you really need to build from source, you will probably find it a LOT easier to just install the binary.

Do the falses there mean that WinPcap did not get installed properly?

No.

I was hoping to find pcap.h

Then, IF you NEED to build from source, you need to install the WinPcap Developer's Pack. WinPcap is just the "run time", sufficient for programs such as Wireshark that have already been built, but not sufficient for software that uses WinPcap and that need to be compiled on your machine - and, apparently, whatever flavor of pcapy you downloaded needs to be built.

(This is similar to the way libpcap is packaged on many Linux distributions - the "libpcap" package just installs the run time, and you need to install a "libpcap-dev" package, or something such as that, to get the header files.)

But if the Windows binary works for you, don't bother with the WinPcap developer's pack.

  • That makes sense about the developer's pack. It was obvious that I was missing **something** I just didn't know what. They don't seem to just have an .egg file I can download, and the .exe looks like it wants to re-install Python (2.5) which I don't want. Also Chrome seems to think the .exe is malware (!) So I think I will try grabbing the Developer's pack and building pcapy. – PurpleVermont Apr 10 '14 at 22:45
  • Downloading the developer's pack and adding pointers to its Include and Lib directories in setup.py got me much further, but the build still failed with a number of unresolved external symbols :-/ – PurpleVermont Apr 11 '14 at 02:22
3

As Guy Harris explained, it's generally easier to download install a binary. If you do build from source:

  1. Download the WinPcap Developer's Pack.
  2. Use pip's --global-option. setup.py is different, but I think pip is preferred over setup.py anyway.

    Here's an example line (substitute in the correct paths for your system; I just referenced them right in the Downloads folder):

    pip install ./pcapy-src-dir --global-option=build_ext --global-option="-LC:\path\to\WpdPack_4_1_2\WpdPack\Lib" --global-option="-IC:\path\to\WpdPack_4_1_2\WpdPack\Include
    

See also this answer.

Community
  • 1
  • 1
jtpereyda
  • 6,987
  • 10
  • 51
  • 80
3

Building on Josh P's answer (which I used to get most of the way there just now):

  1. download the WinPcap Developer's pack
  2. extract the zip file (e.g. c:\users\foo\Downloads\WpdPack_4_1_2)
  3. build using the --global-option to pass in the header and linker locations

When specifying the library folder for the linker, on Windows 7, I needed to specify the x64 version of the lib, not the (default) x32 version of the lib:

pip install pcapy  --global-option="build_ext" 
    --global-option="-Ic:\users\foo\Downloads\WpdPack_4_1_2\WpdPack\include" 
    --global-option="-Lc:\users\foo\Downloads\WpdPack_4_1_2\WpdPack\lib\x64"

I was getting the following link errors when using the ...\lib (x32) version of the file:

       Creating library build\temp.win-amd64-2.7\Release\pcapy.lib and object build\temp.win-amd64-2.7\Release\pcapy.exp

pcapdumper.obj : error LNK2019: unresolved external symbol pcap_dump_close
referenced in function "void __cdecl pcap_dealloc(struct pcapdumper *)" 
(?pcap_dealloc@@YAXPEAUpcapdumper@@@Z)
Woody
  • 69
  • 3
-1

In the pcapy-0.11.1 the setup.py is smarter, even smarter that what they described on their wiki page: https://github.com/CoreSecurity/pcapy/wiki/Compiling-Pcapy-on-Windows-Guide

The investigation demonstrated that's enough to set environment variable WPDPACK_BASE, so in Windows' case it may look like:

set WPDPACK_BASE=C:\Software\WpdPack

It's even able to detect if you need 32 or 64 bit version of these libraries.

Previous answers didn't help me solve the problem, but helped me digging. So they may be bit outdated.

Michał Fita
  • 1,183
  • 1
  • 7
  • 24