C Extensions: calling across extensions
Maxwell Sayles
sayles at cpsc.ucalgary.ca
Wed May 29 17:50:55 EDT 2002
I have two C Extension modules written for python. Within one module I
want to create an instance of an object within another module. Say the
modules are named A and B. Within A I have a creation method that looks
something like:
PyObject* A_new (int param)
{
AType* self = PyObject_New (AType, &AType_definition);
self->param = param;
return (PyObject*)self;
}
within B i try to create an instance of AType like:
PyObject* A_new (int param);
PyObject* somefunction (PyObject* self, PyObject* args)
{
PyObject* p = A_new (5);
return p;
}
both of these functions are in seperate modules in seperate .so files
(linux). I can import module A and everything works perfectly. when i
import module B i get the error:
Import Error: ./B.so: undefined symbol: A_new
i compile both with
gcc -shared -o A.so A.c
gcc -shared -o B.so B.c
do i need to do special declarations for importing and exporting
functions across shared objects for python extension modules? do i need
to compile with a -l option? any help would be appreciated.
thanks, Maxwell Sayles
More information about the Python-list
mailing list