python调用c++ DLL

python

DLL = ctypes.cdll.LoadLibrary("./dll_file.so") #引入dll
DLL.func(mat.ctypes.data // (1 << 16), mat.ctypes.data % (1 << 16)) #获取numpy.array地址

c++

extern "C"

{

void func(void *addr_high, void *addr_low)

{

char *ptr = (char*)(addr_low + addr_high * (1LL << 16))

}

}

编译

g++ -fPIC -shared -o dll_file.so main.cpp

上一篇:小程序 小知识总结


下一篇:收到offer!