gpt4 book ai didi

java - 奇怪的 java.lang.UnsatisfiedLinkError : Native method not found:

转载 作者:行者123 更新时间:2023-12-01 18:27:49 25 4
gpt4 key购买 nike

我正在使用 NDK+OpenCV 来开发应用程序。我有以下问题:

我将所有 native 方法放在 FoodRecgNativeLib.java 中,我想从文件中读取 opencv 矩阵:

//in FoodRecgNativeLib.java

public static void NativeLoadFile(String path, String tag, Mat result)
{
loadsfile(path,tag,result.nativeObj);
return;
}
public native static void loadsfile(String path, String tag, long addr);

//.h file
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ca_uwo_csd_Threads_FoodRecgNativeLib */

#ifndef _Included_ca_uwo_csd_Threads_FoodRecgNativeLib
#define _Included_ca_uwo_csd_Threads_FoodRecgNativeLib
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT void JNICALL Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile
(JNIEnv *, jclass, jstring, jstring, jlong);
#ifdef __cplusplus
}
#endif
#endif

//in .cpp file, .h file is included

JNIEXPORT void JNICALL Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile
(JNIEnv *env, jobject cls, jstring path, jstring tag, jlong result_addr)
{
cv::FileStorage fs(jstring2str(env,path), FileStorage::READ);
Mat& data = *(Mat*)result_addr;;
fs[jstring2str(env,tag)] >> data;
}

谁能检查一下我的代码有什么问题吗?

最佳答案

Java_ca_uwo_csd_Threads_FoodRecgNativeLib_loadsfile 的声明和实现签名不匹配。将实现中的第二个参数类型从 jobject 更改为 jclass

关于java - 奇怪的 java.lang.UnsatisfiedLinkError : Native method not found:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25413547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com