Aditya Ghantasala schrieb am 23.10.2014 um 10:02:
> Actually I did not get what you explained. I will read more to understand.
> But as you suggested I am giving you a simple example:
>
> myModule.pyx
> ---------------------------------------------
> cdef public double returnPlusTen(double arg)
> return arg+10.0
> ---------------------------------------------
>
> Now I do : "cython -3 --cplus myModule.pyx "
> and get myModule.cpp and myModule.h files.
>
> cplusExp.cpp
> ----------------------------------------------
> #include "myModule.h"
> #include "Python.h" // From python3.3m
> void main (){
>
> double k = 10.5;
> double result = returnPlusTen(k);
> printf("The result obtained is :: %f",result);
>
> }
> ---------------------------------------------------------
> I will compile the cplusExp.cpp with g++ by linking with -lpython3.3 flag.
> It produces error saying "in myModule.h : expected constructor and
> destructor before returnPlusTen(double)"
To use a Cython extension module in an actual (directly runnable) C++
application, you need to embed the CPython runtime in that program. Here's
an example:
https://github.com/cython/cython/tree/master/Demos/embed
Cython generated code is not meant to be used stand-alone.
Stefan