Android C层如何加载.so库文件

来源:互联网 发布:可以手写的软件 编辑:程序博客网 时间:2024/06/05 17:56

Android C层如何加载.so库文件:

#include <stdlib.h>#include <stdio.h>#include <dlfcn.h>#include <errno.h>int (*jmain)(int arg1, char* arg2) = NULL;void int callSoJMainFunction(int arg1, char* arg2) {    void* handle = dlopen(szSoPath, RTLD_LAZY);    if (handle == NULL) {        printf(“dlopen file error:%s  %s\n", szSoPath, strerror(errno));        return -1;    } else {        printf("dlopen file OK: %d\n", handle);    }    jmain = dlsym(handle, "main");    if(jmain == NULL) {        printf("get main function error\n");        dlclose(handle);        return -1;    } else {        printf("dlsym OK: 0x%08X\n", jmain);        int result = jmain(arg1, arg2);        dlclose(handle);        return result;    }}


0 0
原创粉丝点击