python下面通过ctypes模块调用c++库的方法
来源:互联网 发布:2016淘宝买家可以贷款 编辑:程序博客网 时间:2024/05/20 07:36
foo.cpp:
#include <iostream>class Foo{ public: void bar(){ std::cout << "Hello" << std::endl; }};int test() { std::cout<<"hello world"<<std::endl; return 0;}extern "C" { Foo* Foo_new(){ return new Foo(); } void Foo_bar(Foo* foo){ foo->bar(); } int Test() { return test(); }}
通过 g++ -o libfoo.so -shared -fPIC foo.cpp 生产foo.so
usec.py
from ctypes import cdlllib = cdll.LoadLibrary('./libfoo.so')#class Foo(object): # def __init__(self): # self.obj = lib.Foo_new() # def bar(self):# lib.Foo_bar(self.obj)lib.Test()#f = Foo()#f.bar() #and you will see "Hello" on the screen
注释掉的是调用c++类的方法,lib.Test()直接调用方法
0 0
- python下面通过ctypes模块调用c++库的方法
- 【Python】Python通过ctypes调用C动态链接库
- python ctypes - python调用C语言库
- python调用的动态连接库的方法(ctypes)
- ctypes: 使用python调用C编写的动态链接库
- python通过ctypes调用dll
- python脚本利用ctypes调用c模块返回字符串
- Python与C之间的相互调用(Python C API及Python ctypes库)
- Python与C之间的相互调用(Python C API及Python ctypes库)【转】
- Python与C之间的相互调用(Python C API及Python ctypes库)
- Python与C之间的相互调用(Python C API及Python ctypes库)
- Python与C之间的相互调用(Python C API及Python ctypes库)
- Python与C之间的相互调用(Python C API及Python ctypes库)
- Python与C之间的相互调用(Python C API及Python ctypes库)
- 神奇的Python ctypes模块
- C/C++ 生成的.so文件,python 用ctypes调用
- Python:使用ctypes库调用外部DLL(附带ctypes c 类型转换图)
- Python 使用库ctypes调用C代码接口
- 网页清除隐藏文字.去除网页文字干扰码的两种方法
- Xavier初始化方法
- Spring 事务笔记
- poj 2442 Sequence
- Leetcode | Count Complete Tree Nodes
- python下面通过ctypes模块调用c++库的方法
- 希尔排序——ShellSort
- svg矢量图实现android多形状图形框架-动脑学院
- Java选项卡(JTabbedPane)的使用
- fgets()函数
- Android应用程序资源的编译和打包过程分析
- Git Pro.1
- 通过三次优化,我将gif加载优化了16.9%
- Hibernate4注解方法