I'm trying to write a binding for a vendor C++ library. I've successfully used snippets such as the below to define init functions in the other modules, but in this one it doesn't seem to work: it compiles fine, but throws the ImportError as soon as I try to import it into a test script. What could be wrong here?
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC initclient(void) {
PyObject* m;
ClientType.tp_new = PyType_GenericNew;
if (PyType_Ready(&ClientType) < 0)
return;
m = Py_InitModule3("client", client_methods, "Client module");
Py_INCREF(&ClientType);
PyModule_AddObject(m, "Client", (PyObject *) &ClientType);
}
This is on 32-bit Linux, with gcc 4.4.4.