学习“用dlopen,dlsym加载动态链接库.so中函数”之摘录
生活随笔
收集整理的這篇文章主要介紹了
学习“用dlopen,dlsym加载动态链接库.so中函数”之摘录
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
參考鏈接:https://www.cnblogs.com/eniac1946/p/7462082.html
直接上代碼:
static void *findSymbol(const char *path, const char *symbol) {void *handle = dlopen(path, RTLD_LAZY);if (!handle) {LOGE("handle %s is NULL", path);return NULL;}void *target = dlsym(handle, symbol);if (!target) {LOGE("symbol %s is NULL", symbol);}return target; }void *target = findSymbol("libc.so", "__system_property_get");dlopen打開失敗,可以用dlerror()查看錯誤,看代碼:
void *dlh; dlh = dlopen("libdes3-32.so", RTLD_NOW | RTLD_GLOBAL); if (dlh == NULL) {printf("dlopen err:%s.\n", dlerror()); }總結(jié)
以上是生活随笔為你收集整理的学习“用dlopen,dlsym加载动态链接库.so中函数”之摘录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学习并整理windows下编译nginx
- 下一篇: 学习nginx接口调用之摘录