java.lang.UnsatisfiedLinkError: Native method not found

前端 未结 1 1554
傲寒
傲寒 2020-12-30 18:46

I\'m trying to make a NDK application, but I get this error:

java.lang.UnsatisfiedLinkError: Native method not found: com.example.hellondk.jni.HelloNDK.hello         


        
相关标签:
1条回答
  • 2020-12-30 19:13

    You're exporting it as a C++ function, but the JNI linker doesn't understand C++ name mangling, so it won't be able to find it.

    You can use extern "C" to have the function exported without C++ name mangling:

    extern "C" JNIEXPORT jint JNICALL Java_com_example_hellondk_jni_HelloNDK_hello(JNIEnv* env, jobject o)
    {
        return (jint) 2;
    }
    
    0 讨论(0)
提交回复
热议问题