开发者

Android NDK: Autogenerate function declarations?

I am trying to use a pre-existing native C library in my android project.. The library builds just fine with the NDK tools...

Now what I've come to understand is that I cannot just call into the library, but my library needs to include jni.h and add specific function declarations, like for example:

JNIEXPORT jint JNICALL Java_com_MultPkg_Mult_mult(JNIEnv 开发者_C百科*, jobject, jint, jint);

But since I'm using an existing library I that is also used on other platforms I don't like the idea of littering the whole code with these definitions that will only end up wrapping my real functions...

Is there a way around this? And if this really is the only way, is there any way to automatically generate these based on my existing C function declarations/definitions?

Much appreciated


Use the javah tool that comes with your JDK as it's not part of the Android's SDK nor NDK.


Use SWIG to auto generate the jni compatible c file. It also generate the .java class so that your android interacts with the java class in which has all the native methods.

Take a look at this : SWIG Android

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜