原文:http://code.google.com/p/pypcap/issues/detail?id=27
Has anyone got PCAP to run on Python 2.7
Comment 1 by tbjhdani...@gmail.com,
Oct 8, 2010
Oct 8, 2010
,
Up
Oct 27, 2010
,
Not up yet... I'm getting following error with latest download gcc -pthread -fno-strict-aliasing -g -O2 -g -O0 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c pcap_ex.c -o build/temp.linux-i686-2.7-pydebug/pcap_ex.o pcap_ex.c:22:20: error: config.h: No such file or directory pcap_ex.c: In function ‘pcap_ex_fileno’: pcap_ex.c:165: error: dereferencing pointer to incomplete type pcap_ex.c: In function ‘pcap_ex_next’: pcap_ex.c:253: error: dereferencing pointer to incomplete type pcap_ex.c: In function ‘pcap_ex_compile_nopcap’: pcap_ex.c:285: warning: implicit declaration of function ‘mktemp’ error: command 'gcc' failed with exit status 1
Oct 27, 2010
,
I get the exact same thing on Mac OS X 10.6.4 Snow Leopard ^
Oct 27, 2010
,
Ok, I think I found a solution. Someone posted a patch here http://trac.umitproject.org/ticket/328 that seems to work! Save the following text to "python27patch" or whatever you want, save it in the same directory as the source code, and type: patch > python27patch. Then just do python setup.py build, pythonsetup.py install, worked for me. Index: pcap_ex.c =================================================================== --- pcap_ex.c (revision 85) +++ pcap_ex.c (working copy) @@ -12,7 +12,7 @@ # include <signal.h> # include <unistd.h> #endif - +#define HAVE_PCAP_FILE #include <pcap.h> #ifdef HAVE_PCAP_INT_H # include <pcap-int.h>
Feb 15, 2011
,
Thanks for posting the info and patch in Comment 6. A tiny correction to the redirection- it should be patch < python27patch
May 24, 2011
,
Hi, I can confirm adding the line "#define HAVE_PCAP_FILE" to pcap_ex.c (from pypcap-1.1) solves the error message below. (FWIW: Ubuntu 11.04, python 2.7) pcap.c:28:12: warning: ‘__Pyx_SetVtable’ declared ‘static’ but never defined pcap.c:29:12: warning: ‘__Pyx_GetVtable’ declared ‘static’ but never defined pcap.c:30:18: warning: ‘__Pyx_CreateClass’ declared ‘static’ but never defined gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include -I/usr/include/python2.7 -c pcap_ex.c -o build/temp.linux-x86_64-2.7/pcap_ex.o pcap_ex.c: In function ‘pcap_ex_fileno’: pcap_ex.c:165:16: error: dereferencing pointer to incomplete type pcap_ex.c: In function ‘pcap_ex_next’: pcap_ex.c:253:12: error: dereferencing pointer to incomplete type pcap_ex.c: In function ‘pcap_ex_compile_nopcap’: pcap_ex.c:285:2: warning: implicit declaration of function ‘mktemp’ error: command 'gcc' failed with exit status 1 make: *** [all] Error 1
Jan 3, 2012
,
I had to use this patch in addition to the one above, to work with Ubuntu 10.11 (oneiric): --- setup.py 2005-10-16 19:07:03.000000000 -0400 +++ setup.py 2012-01-03 12:22:04.761298898 -0500 @@ -46,7 +46,7 @@ incdirs = [ os.path.join(d, sd) ] if os.path.exists(os.path.join(d, sd, 'pcap.h')): cfg['include_dirs'] = [ os.path.join(d, sd) ] - for sd in ('lib', ''): + for sd in ('lib', 'lib/i386-linux-gnu'): for lib in (('pcap', 'libpcap.a'), ('pcap', 'libpcap.dylib'), ('wpcap', 'wpcap.lib')):
Feb 28, 2012
,
look at here:http://code.google.com/p/pypcap/issues/detail?id=36