开发者

Calling a C++ DLL in Python which returns an object reference

开发者 https://www.devze.com 2023-03-19 19:19 出处:网络
After a long research i have decided to write a question. I have a C++ DLL which has one exported funct开发者_运维技巧ion : ObjectType* getInstance()

After a long research i have decided to write a question. I have a C++ DLL which has one exported funct开发者_运维技巧ion : ObjectType* getInstance() With this instance, the function returns, i can get access to all the other public functions.

My problem now is, that i want to use this thing in Python. When i access getInstance with ctypes i only get an integer value instead of an instance. The next thing i tried was to write an Python extension in C++. But this also didn't work out.

Any ideas.

Thank you very much for your help.

Best regards.


As far as I know, you can't access a C++ type directly from Python. You have to wrap it with some (often a lot of) C or C++ code: it's not difficult, but it does take time. See Extending and Embedding the Python Interpreter.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号