I. Package Download
WinPcap installer: http://www.winpcap.org/archive/
WinPcap WpdPack: http://www.winpcap.org/archive/
Mingw: http://www.mingw.org/
pycap: http://code.google.com/p/pypcap/
sendpkt: http://code.google.com/p/sendpkt/
dpkt: http://code.google.com/p/dpkt/
pexports: http://www.emmestech.com/moron_guides/moron1.html
II. Compile
1> Install Mingw
<> : install
<> : under ..\bin, change mingw32-make.exe to make.exe
<> : add into env variable
<> : add into env variable
<> : check with g++
2> Install winpcap
<> : install
3> Generat libpython27.a (for mingw usage)
<> : goto <Python Home>\libs
<> : run pexports %dll_name% >%def_file%
Sample : pexports.exe c:\WINDOWS\system32\python27.dll >python27.def
<> : run dlltool -d %def_file% -l %library% (please do not forget that gcc linker expects library files to have "lib" prefix, e.g. libpython20.a for python20.dll)
Sample : dlltool -d python27.def -l libpython27.a
<> : run pexports %dll_name% >%def_file%
Sample : pexports.exe c:\WINDOWS\system32\python27.dll >python27.def
<> : run dlltool -d %def_file% -l %library% (please do not forget that gcc linker expects library files to have "lib" prefix, e.g. libpython20.a for python20.dll)
Sample : dlltool -d python27.def -l libpython27.a
4> Compile pypcap
<> : unzip both pypcap and wdpack into same folder (pypcap 和 wdpack为同级目录 )
<> : create setup.cfg as below
- [build]
- compiler=mingw32
<> : python setup.py config
<> : python setup.py build
<> : python setup.py install
5> install senddpkt with similiar process
6> verification
under cmdlie, type python:
6> verification
under cmdlie, type python:
- >>> import pcap
- >>>
III. FAQ
1> ERROR : "couldn't find pcap build or installation directory"
A: 目录结构:
base\
pypcap
WpdPack
2> ERROR : Undefined reference to `_imp___Py_NoneStruct
A: 缺少python2x.a文件,check II. 3