简体   繁体   English

如何仅使用swig编译的dll和头文件

[英]How to use swig with compiled dll and header file only

I have read some docs from SWIG documentation (related to c++ code), but can't figure out if it is possible to genereate Python extension module in case I have compiled dll (no source code provided) and header file with all functions declared in dll. 我已经阅读了SWIG文档中的一些文档 (与c ++代码相关),但是如果我编译了dll (没有提供源代码)和头文件以及所有函数声明的话,我都无法弄清楚是否可以生成Python扩展模块。 DLL。
If someone has the same problem and solve it, could you provide some useful example? 如果有人有同样的问题并解决它,你能提供一些有用的例子吗?
Thanks in advance. 提前致谢。

Yes, it is possible. 对的,这是可能的。 SWIG only uses the headers to generate wrapper functions. SWIG仅使用标头生成包装函数。 Here's a simple SWIG file: 这是一个简单的SWIG文件:

%module mymod
%{
#include "myheader.h"
%}

%include "myheader.h"

Then: 然后:

swig -python -c++ mymod.i

Then compile and link the generated code as a Python extension DLL. 然后编译并将生成的代码链接为Python扩展DLL。 You will also need to link in the .lib for the wrapped DLL. 您还需要在.lib中链接包装的DLL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM