开发者

Cython - properly declaring C funs

I'm having trouble with runn开发者_如何学运维ing 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜