Windows下python使用SWIG调用C++ dll
2014-04-22 12:59
1031 查看
有一dll和对应的lib文件,含有以下函数:
test.h
则可以编写对应的.i文件:
test.i
%module test
%{
#define SWIG_FILE_WITH_INIT
#include "dlltest.h"
%}
int add(int a, int b);
class Test { private: int a; int b; public: int r; Test(int, int); int add(); int getV(Test*); }; 使用swig:
swig -c++ -python test.i
得到对应的test.py和test_wrapper.cxx文件。
将得到的这两个文件以及库lib文件一起编译成一个test.dll文件,再将该dll文件改名为_test.pyd。
将test.py和_test.pyd以及依赖的dll库放到同一文件夹下,即可再该文件夹下import test并调用
test.h
class Test { private: int a; int b; public: int r; Test(int, int); int add(); int getV(Test*); };
则可以编写对应的.i文件:
test.i
%module test
%{
#define SWIG_FILE_WITH_INIT
#include "dlltest.h"
%}
int add(int a, int b);
class Test { private: int a; int b; public: int r; Test(int, int); int add(); int getV(Test*); }; 使用swig:
swig -c++ -python test.i
得到对应的test.py和test_wrapper.cxx文件。
将得到的这两个文件以及库lib文件一起编译成一个test.dll文件,再将该dll文件改名为_test.pyd。
将test.py和_test.pyd以及依赖的dll库放到同一文件夹下,即可再该文件夹下import test并调用
相关文章推荐
- 使用SWIG实现Python调用C/C++代码
- Windows下QT中用C++调用Python之四 - 第三方扩展的使用
- Python调用windows下DLL详解 - ctypes库的使用
- python通过swig调用c++dll时指针的用法
- Python调用C/C++(使用SWIG)
- Python调用windows下DLL详解 - ctypes库的使用
- 使用Visual Studio,几步实现Python C++扩展,以及DLL调用
- centos7下使用swig扩展python接口来调用c++ 实现声纹识别
- Python调用windows下DLL详解 - ctypes库的使用[转]
- Python调用windows下DLL详解 - ctypes库的使用
- [C++/Python] 如何在Python中使用一个DLL? (Windows环境)
- 使用python2.7中ctypes库调用windows下的dll
- Linux下利用SWIG完成Python对使用OpenCV的C++文件的调用
- Python调用windows下DLL详解 - ctypes库的使用
- c++生成dll使用python调用dll的方法
- Python调用windows下DLL详解 - ctypes库的使用
- Python调用C++函数(SWIG,VS2013使用numpy.i完成Numpy与C++数组转换)
- 使用 SWIG 实现 Java 调用 C++ DLL
- Python调用windows下DLL详解 - ctypes库的使用
- windows下用swig实现python调用C\C++的方法