|
Re: trouble swigging a library: msg#00126programming.swig
Try to call your .so file _hid.so so that "import hid" will actually load hid.py (this one has an init function) which will then load _hid.so. On Mon, 2004-05-24 at 16:15, Martin F Krafft wrote: > Hi all, > > I would like to use Swig to make a Python wrapper to a library > I wrote in C. The library is installed in /usr/lib and works fine > with C. It's an access library for USB HID devices without requiring > kernel support. Now I need to use it from Python... > > I thus created a .i file for the API and compiled it: > > swig -python hid.i > > cc -fpic -I/usr/include/python2.3/ -I../include \ > -DHID_INTERNAL -c -o hid_wrap.o hid_wrap.c > > No errors. > > I then linked it: > > ld -shared -lusb -lhid hid_wrap.o -o hid.so > > Also, no errors. > > Now I fire up python and try to import the module, but that fails: > > Traceback (most recent call last): > File "./startup.py", line 3, in ? > from hid.so import * > ImportError: dynamic module does not define init function (inithid) > > It seems that everything compiled fine though: > > $ ldd hid.so > libusb-0.1.so.4 => /usr/lib/libusb-0.1.so.4 (0x40010000) > libhid.so.0 => /usr/lib/libhid.so.0 (0x40019000) > libc.so.6 => /lib/tls/libc.so.6 (0x40026000) > /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) > > What am I doing wrong? > > Thanks for any help! > > If you want to download the library in question: > > cvs -d :pserver:anoncvs@xxxxxxxxxxxx:/home/cvs/external login > [empty password] > cvs -z3 -d :pserver:anoncvs@xxxxxxxxxxxx:/home/cvs/external co libhid > > You can find ./swig in there... -- Anton Deguet Systems Engineer ERC CISST Johns Hopkins University http://cisstweb.cs.jhu.edu 410 516 5261 _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | trouble swigging a library: 00126, Martin F Krafft |
|---|---|
| Next by Date: | Re: how to prevent objects from being garbage collected.: 00126, Marcelo Matus |
| Previous by Thread: | trouble swigging a libraryi: 00126, Martin F Krafft |
| Next by Thread: | Re: trouble swigging a library: 00126, Martin F Krafft |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |