[C++-sig] [Boost.Python] Wrapping C library functions

Charles Solar charlessolar at gmail.com
Mon Feb 15 01:43:52 CET 2010


If you want to wrap the library in C I believe you will have to use the
standard python API, as boost requires C++ features.
It sounds like you do not want to write a wrapper library and instead add
code to leptonica to make it python import-able.  I would not suggest this
approach.

If you want to write a wrapper around the C library in C++ you can use boost
python, then in python you would import your wrapper which would allow you
to use the C library in python using your C++ wrapper functions.

If you just want to add code to this library and make it work in python
immediately check out SWIG, although I am not sure if swig produces cpython
code or boost python C++ code.

On Sun, Feb 14, 2010 at 6:32 PM, TP <wingusr at gmail.com> wrote:

> Suppose I am attempting to use a C (not C++) library that has an .h file
> with things like this:
>
>  extern PIX * pixCreate ( l_int32 width, l_int32 height, l_int32 depth );
>  extern void pixDestroy ( PIX **ppix );
>
>  extern PIX * pixClone ( PIX *pixs );
>  extern PIX * pixCopy ( PIX *pixd, PIX *pixs );
>
> Is it possible to use Boost.Python to wrap such functions?
>
> In particular, note that pixDestroy() is going to want the address of the
> pointer returned by pixCreate().
>
> (This is from the leptprotos.h file of the Leptonica Image Processing
> library at leptonica.com)
>
>
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100214/1e03ce0f/attachment.htm>


More information about the Cplusplus-sig mailing list