从Python调用C ++ DLL

从Python调用C ++ DLL

问题描述:

我想知道是否可以使用ctypes从Python访问C ++ DLL并从中运行函数(或类方法)。如果没有,还有另一种方法吗?

I'd like to know if it is possible to use ctypes to access C++ DLLs from Python and run functions (or class methods) from them.If not, is there another way to do this?

此问题已得到回答很多次这是一个完全相同的副本!

总之,您还不能使用Ctypes做到这一点,但是您可以使用许多其他代码生成器来完成这项工作。 SWIG Boost.Python 是最受欢迎的两个。

In summary, no you can't do it with Ctypes (yet) but there are a number of other code generators you could use to do the job. SWIG and Boost.Python are two of the most popular.