如何使用C++ Dll在Python中
我有一个用C ++编写的功能和结构的库。它也可以在CS文件中使用包装器在C#中使用,该包装器描述了从DLL调用功能的C#接口。也就是说,要使用C#API,您只需要一个DLL文件。我该如何为Python做同样的事情?除DLL外,我还拥有.h文件,但没有.cpp文件。
I have a library with functions and structures written in C++. It can also be used in C# using a wrapper in a cs-file, which describes C# interfaces that call functions from a DLL. That is, to use the C# API, you only need a DLL file. How can I do the same for python? In addition to the DLL, I also have the .h file, but not the .cpp file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 ctypes ,您必须具有C中间层的C中间层 让我们
说我们有一个名为duck.cpp
文件
的
You will need to use ctypes and you have to have an intermediate layer of C.
Let us say we have a file called duck.cpp
The compiled, here with G++, I will generate an .so and not a dll as I am on Linux:
Then in Python