swig c++生成python接口 使用记录

2019-09-25  本文已影响0人  flyingstarxx

下载安装

参考官网说明
http://www.swig.org/Doc4.0/SWIGDocumentation.html#Preface_unix_installation

swig使用

  1. 建立接口文件 xxx.i
    参考
    http://www.swig.org/tutorial.html
    之后在命令行敲入下列语句,形成wrap文件

swig -c++ -python xxx.i

  1. 构建动态链接库

c++ xxx1.cpp xxx2.cpp ... xxx_wrap.cxx -I/usr/local/include/python3.x -fPIC -shared -o _xxx.so -lpthread -lrt

  1. 构建python文件,import上述构建过程中生成的xxx.py库文件即可
上一篇 下一篇

猜你喜欢

热点阅读