安卓dlopen dlsym dlclose

动态加载so库

1. dlopen("绝对路径/lib.so”) 函数原型:

void* dlopen(const char* __filename, int __flag);

2. dlsym 函数原型 void* dlsym(void* __handle, const char* __symbol); 这个返回值需要 reinterpret_cast<int*> 强制类型转换 获取值需要解引用
3. dlcose int dlclose(void* __handle);
1 void* handle = dlopen(full_path,RTLD_LAZY);
2 int* b = reinterpret_cast<int*>(dlsym(handle, "b"));
3 dlclose(handle);

 



posted on 2025-05-27 19:18  小沙盒工作室  阅读(27)  评论(0)    收藏  举报