logo       

trouble swigging a library: msg#00125

programming.swig

Subject: trouble swigging a library

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...

--
Martin F. Krafft Artificial Intelligence Laboratory
Ph.D. Student Department of Information Technology
Email: krafft@xxxxxxxx University of Zurich
Tel: +41.(0)1.63-54323 Andreasstrasse 15, Office 2.18
http://ailab.ch/people/krafft CH-8050 Zurich, Switzerland

Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver!
Spamtraps: krafft.bogus@xxxxxxxx madduck.bogus@xxxxxxxxxxx

"an intellectual is someone who has found
something more interesting than sex."
-- edgar wallace

Attachment: signature.asc
Description: Digital signature

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise