From: Raffaele S. <raf...@gm...> - 2010-09-01 01:12:10
|
I'm trying to build a Python extension around Linux Wireless Extension You can download the WE sources here http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/wireless_tools.29.tar.gz The file I need to wrap is iwlib.h, so I wrote this interface file NOTE: you have to remove __attribute__ ((packed)) /* iwlib.swig */ %module wireless %{ #include "iwlib.h" %} %include "iwlib.h" then run swig. I got iwlib_wrap.c, then I tried to compile it this way $ python setup.py build_ext --inplace running build_ext building '_wireless' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c iwlib_wrap.c -o build/temp.linux-i686-2.6/iwlib_wrap.o iwlib_wrap.c: In function ‘_wrap_iw_pk_event_len_set’: iwlib_wrap.c:3133: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_event_len_get’: iwlib_wrap.c:3155: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_event_cmd_set’: iwlib_wrap.c:3191: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_event_cmd_get’: iwlib_wrap.c:3213: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_event_u_set’: iwlib_wrap.c:3249: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_event_u_get’: iwlib_wrap.c:3271: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_new_iw_pk_event’: iwlib_wrap.c:3284: error: invalid application of ‘sizeof’ to incomplete type ‘struct iw_pk_event’ iwlib_wrap.c: In function ‘_wrap_iw_pk_point_pointer_set’: iwlib_wrap.c:3340: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_point_pointer_get’: iwlib_wrap.c:3362: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_point_length_set’: iwlib_wrap.c:3398: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_point_length_get’: iwlib_wrap.c:3420: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_point_flags_set’: iwlib_wrap.c:3456: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_iw_pk_point_flags_get’: iwlib_wrap.c:3478: error: dereferencing pointer to incomplete type iwlib_wrap.c: In function ‘_wrap_new_iw_pk_point’: iwlib_wrap.c:3491: error: invalid application of ‘sizeof’ to incomplete type ‘struct iw_pk_point’ error: command 'gcc' failed with exit status 1 I also tried a different interface file (without the %include, BTW what's the need for both #include and %include?) /* iwlib.swig */ %module wireless %{ #include "iwlib.h" %} this way the wrapper C file gets compiled without errors, but then I can't use any function in the wireless python module. Here is my setup.py #!/usr/bin/env python from distutils.core import setup, Extension wirelessModule = Extension("_wireless", sources = ["iwlib_wrap.c"], ) setup( name = "wireless", author = "Raffaele Sgarro", version = "0.1", ext_modules = [wirelessModule], ) So can you show me the way for getting a Python module from iwlib.h? |