On Wed, Dec 14, 2011 at 7:09 PM, Hugo Parente Lima
<hugo.l...@openbossa.org>wrote:

> On Wednesday 14 December 2011 12:05:57 anatoly techtonik wrote:
> > Hello,
> >
> > Is it possible to generate bindings for C libraries with shiboken?
>
> Yes you can, maybe shiboken isn't the better tool to bind C code, but it
> can
> do the job, and if you want a nicer and more OO API for your bindings you
> can
> do what Marcelo did here:
>
> http://www.setantas.net/blog/2011/03/08/python-bindings-for-libepub-using-
> shiboken/


This tutorial requires writing C++ wrapper around C code. Is it possible to
avoid that?


> You also need to care care of putting all your includes inside a "extern
> C",
> because shiboken generates C++ code.
>

Could you, please, expand this a bit? Do I need to do this in avbin.h file,
or in generated .cpp/.h files?
(If I was comfortable with C/C++, I would probably already created Python
binding by hand).

> I understand that C is a subset of C++, but I can't generate anything from
> > C header file.
> > For example, I want to create binding for avbin_get_version() function
> > available from
> > https://github.com/AVbin/AVbin/blob/master/include/avbin.h
> >
> > I do:
> > $ shiboken lib/AVbin/include/avbin.h typesystem.xml
> >
> > Where typesystem.xml is the following:
> >
> > <?xml version="1.0"?>
> >
> > <!-- the name of the module as it will be imported from Python-->
> > <typesystem package='AVbin'>
> >   <function signature='int avbin_get_version()' rename='version'/>
> > </typesystem>
> >
> >
> > First of all it always complains about "No C++ classes found!"
>
> You can ignore this message.
>
> > Then I see the message:
> > Global function 'int avbin_get_version()' is specified in typesystem, but
> > not defined. This could potentially lead to compilation errors.
> >  If I modify the <function> with signature='avbin_get_version()' I get
> > another error:
> > skipping function '::avbin_get_version', unmatched return type 'int'
>
> Probably this function wasn't found in your global header, the header file
> read by shiboken to find what classes/function can be bound, look at the
> log
> files generated by the generator.


They are empty. 1032 bytes each.
Console output: http://pastebin.com/fU7rzmXi
Generated files:
- out/AVbin/avbin_module_wrapper.cpp - http://pastebin.com/GUkTiksN
- out/AVbin/avbin_python.h - http://pastebin.com/KmGDW8xi

I've uploaded the project to:
https://bitbucket.org/techtonik/shiboken-avbin
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to