Problem in calling custom shared library from python
Jarkko Vatjus-Anttila <[email protected]> Thu, 8 Mar 2012 13:07:16 +0200
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CAP8GwZ8hHYAnfAytACucfqqjxogSk5=41o1dwT-PwJzB4pDFVw@mail.gmail.com> |
Hello, I'm introducing myself to the ctypes python extension, and it really seems suiting my needs for the current project. I've been writing a test program to teach myself the secrets of ctypes, and it runs very well, apart from a slight problem. I'm running the code on 64-bit linux box. I have created a shared library, with a C API, as defined in my testlib_core.h: #ifndef testlib_core_h #define testlib_core_h int init(void); int store(int); int get(void); int clear(void); int destroy(void); #endif // testlib_core_h Behind of that API I have a c++ singleton class implementation which handles eventually all the requests made through the API. All this works well in basic principle. However, the problem is the methods for calling the API. I cannot use the names defined in the declarations, e.g. init(), store(), etc. If I call directly their mangled counterparts, like in this case _Z4initv() and _Z5storei(), those work just as I need. I figured that I would need the h2xml/xml2py conversion tools, but the problem there is that the .py output from xml2py is empty. The XML file itself is ok, and it contains all the information which exists in my shared lib, but still the only thing which exports into the .py file is only these lines: from ctypes import * __all__ = [] Which is not helping much. So, taking a look at the simplicity of the header file above, I do not understand why I cannot get the automatic python generation of the API to work. Any advice for the newbie fellow in ctypes world? :) Br - jarkko ------------------------------------------------------------------------------ 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/ _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users