Can Cython code be compiled in dll, so can a C ++ application call it?

I have a C ++ program, and it has the appearance of a plug-in structure: when the program starts, it looks for a DLL in the plug-in folder with certain exported function signatures, such as:

void InitPlugin(FuncTable* funcTable); 

Then the program will call the function in the dll to initialize and pass the function pointers to the dll. From this moment, the dll can talk to the program.

I know that Cython allows you to call a C function in Python, but I'm not sure if I can write Cython code and compile it in dll so that my C ++ program can initialize it. Sample code will be great.

+4
source share
1 answer

I would suggest that it would be difficult to call it directly, since Cython is so heavily dependent on Python runtime.

It is best to embed the Python interpreter directly into your application, for example. as described in this answer , and call your Cython code from the interpreter. This is what I will do.

0
source

Source: https://habr.com/ru/post/1499647/


All Articles