[Pyrex] Dynamic wrapping of external C libraries?

Jim Kleckner jek-gmane at kleckner.net
Fri Oct 26 19:20:13 CEST 2007


The new api functionality makes it easy to satisfy C function
and data linkage dynamically at runtime very nicely without the
complexities of creating and linking separate shared objects.

There is the special case of having an existing C library with
its own header file that you would like to make available with a
pxd to a number of pyx files.

You would like to link the library functions into the shared
object of the wrapper pyx and perform the dynamic linkages for
them.

Does the api mechanism give you a succinct way of doing this now?

I'm attaching an example that illustrates this.
What is sort of wanting is something weird like:
     cdef public extern from "module.h":
         ctypedef double  ModuleDouble
         ModuleDouble cLibSquare "libSquare"(ModuleDouble a)

Without it you get:
testcimport/testcimport.usetest.c:153: undefined reference to `_libSquare'

Note that you need to add the parent directory to your PYTHONPATH
in order for test.py to find testcimport.*.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcimport.tgz
Type: application/x-compressed
Size: 2080 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20071026/0f5e9433/attachment.bin 


More information about the Pyrex mailing list