Cython for c/c++ functions with non-standard libraries included?

27 views
Skip to first unread message

Pengyao Jiang

unread,
Aug 24, 2016, 1:29:55 AM8/24/16
to cython-users
Hi there,

I'm new to Cython, but I want to use it to write the interface between a few c/c++ functions and python. In the c/c++ function, some non-standard libraries are included, in which some data structures are defined. I'm just wondering structurally, how this can be done with Cython. Do I need to write separate .pxd files for all the data structure/function that I will use from those libraries and cimport to the .pxd file that contains the function I wrote? Do I just need to write one .pyx file for the function I define? Do you have some simple examples for that? I tried but did not find such example from the online user's guide. Thanks so much in advance!

Hai Nguyen

unread,
Aug 24, 2016, 1:49:38 AM8/24/16
to cython-users
On Tue, Aug 23, 2016 at 7:18 PM, Pengyao Jiang <pyji...@gmail.com> wrote:
Hi there,

I'm new to Cython, but I want to use it to write the interface between a few c/c++ functions and python. In the c/c++ function, some non-standard libraries are included, in which some data structures are defined. I'm just wondering structurally, how this can be done with Cython. Do I need to write separate .pxd files for all the data structure/function that I will use from those libraries and cimport to the .pxd file that contains the function I wrote? Do I just need to write one .pyx file for the function I define? Do you have some simple examples for that? I tried but did not find such example from the online user's guide. Thanks so much in advance!

Pengyao Jiang

unread,
Aug 24, 2016, 11:30:47 AM8/24/16
to cython-users
Hi Hai,

Maybe I did not make my question clear. In the c++ example in the tutorial for example, if in the Rectangle.h, it includes other libraries, such as #include <Eigen> , #include <gsl/gsl_randist.h>, some data structures will be used as parameters for the functions in Rectangle.h, and some functions from these libraries will be called. What is the Cython structure look like if I want to call functions from Rectangle.h? 
Reply all
Reply to author
Forward
0 new messages