1)image_api.h定义了以下方法 - int process_image(const char * svgData,void ** mapData);
2)现在我需要调用此方法并将正确的值传递给从image_api.so文件加载的process_image
- 在JNI C包装器代码中创建void **实例的正确方法是什么?
3)
JNIEXPORT jint JNICALL Java_JNITest_process_image(JNIEnv *env, jstring svgData, jobject mapData, jint status) {
const char *str;
str = (*env)->GetStringUTFChars(env, svgData, NULL);
**status = process_image(str, (void**)&mapData);**
return status;
}
////////////
我在调用process_image时遇到UnsatisfiedLinkError,因为方法签名不匹配
答案 0 :(得分:1)
在您的代码中
JNIEXPORT jint JNICALL
Java_JNITest_process_image(JNIEnv *env,
jstring svgData,
jobject mapData, // this is some Java object, you need to access it
// take a look here:
// http://jnicookbook.owsiak.org/recipe-No-020/
jint status // you don't need that, and you can't return value
// like this in JNI
) {
const char *str;
str = (*env)->GetStringUTFChars(env, svgData, NULL);
// Question is ... what exactly process_image does?
// without any additional knowledge about process_image
// it is hard to guess what goes here
int status = process_image(str, &pointer_to_some_memory_region );
return status;
}