Wrapping a Python function using NumPy arrays in C++

余生长醉 提交于 2019-12-08 05:44:02

问题


I have a bunch of functions written in python (for rapid prototyping). My main project is in C++ and I wanna call these functions from my C++ program.

These functions use some specialized python modules like numpy, pyside etc.

I tried using the "--embed" functionality of Cython to convert these functions to a C file and then compile that to an object file. Only problem is, Cython converts these functions into standalone programs, ie. makes a main() function in the .c files it creates. I don't want that, I just wanna be able to call them from my C++ program and use the results I obtain.

Are there any other alternatives, I could use to achieve this (Python/C API, SWIG etc)? Or am I using cython to embed python wrong?

I am using Python3 and Cython 0.22.1.

来源:https://stackoverflow.com/questions/31516235/wrapping-a-python-function-using-numpy-arrays-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!