【发布时间】:2015-08-06 06:07:47
【问题描述】:
我可以调用动态库(.so)中C++类的常用函数,但不知道如何调用动态库(.so)中C++类的构造函数。
JNIEXPORT jint JNICALL Java_com_example_hellobreakdd_MainActivity_helloBreak (JNIEnv *, jobject){
void *handle;
double (*cosine)(double);
char *error;
handle = dlopen("libtest.so", RTLD_NOW);
if (!handle) {
__android_log_print(ANDROID_LOG_ERROR, "start", dlerror());
}
*(void **) (&cosine) = dlsym(handle, "Add");
printf("%f\n", (*cosine)(2.0));
dlclose(handle);
return 1;
}
【问题讨论】:
-
首先你需要一个class ...
-
那么,我需要做什么?任何帮助都会非常重要。
标签: c++ constructor shared-libraries