deepblue
deepblue

Reputation: 8596

Cython - properly declaring C funs

I'm having trouble with running a bare example.

I'm using this to declare a function in Cython coming from cinterf.h header:

cdef extern from 'cinterf.h':  
int xsb_init_string(char* p_xsb_path)

The declaration in the C header file is:

DllExport extern int call_conv xsb_init_string(char *);

both DllExport and call_conv are macros defined elsewhere, and resolve to GCC compiler directives.
do I have to use those as well inside cdef to fully match the declaration?

When I call xsb_init_string() as:

xsb_init_string('some string')

The python interpreter gives me:

'ImportError: ./py_ext.so: undefined symbol: xsb_init_string'

Am I declaring the xsb_init_string() signature properly, inside cdef?

Upvotes: 2

Views: 488

Answers (1)

Giuseppe Ottaviano
Giuseppe Ottaviano

Reputation: 4633

You need to link to the DLL the library that contains the implementation of xsb_init_string.

If you are using distutils to compile the Cython module, you can pass options to the linker to include libraries.

Upvotes: 2

Related Questions