Re: Problem in calling custom shared library from python

Thomas Heller <[email protected]> Fri, 09 Mar 2012 08:29:42 +0100
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Am 08.03.2012 21:13, schrieb Jarkko Vatjus-Anttila:
> On Thu, Mar 8, 2012 at 3:25 PM, Thomas Heller <[email protected]
> <mailto:[email protected]>> wrote:
>
>
>     The h2xml/xml2py tools parse the header file and then look for the
>     functions in the shared library, but they only look for the unmangled
>     names - they don't support C++ name mangling.
>
>     So, it would be best (if you can control the C/C++ source code) to
>     change the header so that the functions are compiled with unmangled
>     names. OTOH, the simple header file that you show above does not really
>     justify the use of h2xml/xml2py, instead you can trivially call the
>     functions with ctypes.
>
>
> Thanks for the reply! Now that you say it aloud, it is obvious. :) The
> mangling is exactly because of the c++ compiler. I tried the same thing
> with C, and there is no problem in calling the functions with their real
> name, So, in that respect problem solved.
>
> For those c++ mangled types, the XML output from gcc-xml has all the
> needed information to format tables for python to make the calls with
> real function names. But, I take from your comment that this is not the
> task, nor purpose of the h2xml/xml2py pair. For that purpose I could
> write my own quick parser, if I see real need for it.

Can't you simply define the functions as 'extern "C"'?

Thomas


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/