Wednesday, 21 August 2013

java.lang.UnsatisfiedLinkError: Native method not found When using header

java.lang.UnsatisfiedLinkError: Native method not found When using header

I have the following...
jniinterface.h
#include <jni.h>
extern "C" {
JNIEXPORT void JNICALL Java_com_gleason_finance_JniLib_init(JNIEnv *
env, jobject obj, jdouble SO, jdouble U, jdouble D, jdouble R);
};
jniinterface.cpp
#include "jniinterface.h"
JNIEXPORT jdouble JNICALL Java_com_gleason_finance_JniLib_init(JNIEnv *
env, jobject obj, jdouble SO, jdouble U, jdouble D, jdouble R, jint N,
jdouble K)
{
return 0.0;
}
But this returns the following....
E/AndroidRuntime( 3638): java.lang.UnsatisfiedLinkError: Native method not
found: com.gleason.finance.JniLib.init:(DDDDID)D
It works fine if I change jniinterface.cpp to...
#include <jni.h>
extern "C" JNIEXPORT jdouble JNICALL
Java_com_gleason_finance_JniLib_init(JNIEnv * env, jobject obj, jdouble
SO, jdouble U, jdouble D, jdouble R, jint N, jdouble K)
{
return 0.0;
}
It works, I am kind of new to C++ so am I doing something wrong? Should I
just remove the header? Why doesn't it work with the header?

No comments:

Post a Comment