我想在我的python應用程序中使用C++庫。我可以在python中加載dll,但找不到解決方案,如何創建該C++ dll中的類的實例並調用該onject上的方法。創建一個C++類的實例並在Python中調用它的方法
下面是我做的和想
C++代碼裏面My.dll
class MyClass
{
public:
MyMethod(int param);
}
Python代碼
from ctypes import *
myDll = windll.LoadLibrary("My.dll")
我想要做以下
myClassInstance = myDll.InstantiateMyClass()
myClassInstance.MyMethod(5)
你應該看看Boost :: Python –
你甚至不能這樣做混合不同的C++編譯器,從來沒有一種不同的語言。 [聽@CatPlusPlus並用Python類型編寫一個完整的Python擴展。](http://stackoverflow.com/questions/7196118/creating-an-instance-of-ac-class-and-calling-methods-on在python/7196380#7196380) –