python调用dll、so库
因为挺简单的,直接上代码。
界面使用pyqt画的
1.引入库以及获取库方法
代码如下(示例):
/*可以看注释帮助理解*/
import sys
from ctypes import * //python引用C++库的模块
import threading//线程
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog//界面类
from mainWindow import Ui_Dialog//ui源码
#python回调函数
def _callback(para):
return 1
CALLBACK =CFUNCTYPE(c_int,c_int)//回调函数
callBackFunc = CALLBACK(_callback)
//写一个类加载dll中方法
class testdll:
def __init__(self):
self.cdll = cdll.LoadLibrary("./xxx.dll")
return
def ownFuncB(self):
self.cdll.FuncC()
return
def ownFuncC(self,a,b,c,d,e,f):
self.cdll.FuncD(a,b,c,d,e,f)
return
def ownFuncD(self,a,b,c,d,e,f):
self.cdll.<