pcapy-ng icon indicating copy to clipboard operation
pcapy-ng copied to clipboard

Add info on how to compile on windows

Open sorin25 opened this issue 2 years ago • 3 comments

It took me a while to figure this out, hope it helps others

sorin25 avatar Jan 25 '23 21:01 sorin25

Unfortunately the info in this PR did not work for me. In my case the WPDPACK_BASE envar didn't help the MSVC linker find the pack files.

I analyzed the error message to see where the linker actually attempts to locate the pack header files. Here are 3 relevant paths:

  • c:\wpdpack\Include
  • %VIRTUAL_ENV%\include (e.g. C:\Users\user\.virtualenvs\projectname-slug\include)
  • <Python install dir>\include (e.g. C:\Python310\include)

So the header files should be placed in any of these directories.

Additionally, this package requires lib files (wpcap.lib+Packet.lib) be placed in one of these directories:

  • c:\wpdpack\Lib\x64
  • %VIRTUAL_ENV%\libs (e.g. C:\Users\user\.virtualenvs\projectname-slug\libs - not to be confused with lib)
  • <Python install dir>\libs (e.g. C:\Python310\libs - again, not to be confused with lib)

It would seem that unzipping the WPD archive directly to C:\wpdpack is most straightforward, however it does clutter your root folder...

moomoohk avatar Feb 12 '23 22:02 moomoohk

If you look at the setup code you can clearly see that WPDPACK_BASE is used to construct the include and library directories for the build. The fact that it defaulted to c:\wpdpack\ in your case seems to indicate that you haven't actualy defined WPDPACK_BASE variable. How exactly did you define the WPDPACK_BASE ?

IIRC, this worked for me:

set WPDPACK_BASE=...
pip install pcapy-ng

image

I haven't seen any recomandation on the WinPcap on a unzip location, and I doubt anyone would naturaly chose c:\wpdpack\ without specific guidance, so rather than confuse the issue with 2 options, I would go with the most flexible one. Maybe add more info on how to setup the environment variable ?

sorin25 avatar Feb 12 '23 23:02 sorin25

Ah, that looks very much in order... I can't explain why it didn't work for me, I must have made a typo when setting the variable.

Thanks for clarifying that

moomoohk avatar Feb 13 '23 09:02 moomoohk