c++ %module mymodule %{ %} bash swig -python interface.i c++ int add(int, int); c++ #include "myheader.h" int add(int a, int b) { return a + b; } bash gcc -c myheader.c gcc -shared myheader.o -o mymodule.so bash gcc -c myheader.c gcc -shared myheader.o -o mymodule.pyd python import mymodule result = mymodule.add(5, 3) print("Result:", result) bash python main.py


上一篇:
下一篇:
切换中文