Question

I want to convert my cpp code for static library into Android library. For this, I'm attempting to use NDK. But I read NDK documentation and it said that only source code is able to be input for building, "Android.mk". My Questtion is "Is there any way to build static library for Android system with my cpp library?" Top module of my cpp library is header file and it can be built on Windows system as ".lib".

Thank you!

Was it helpful?

Solution

Your cpp library should be built with NDK toolchain as "libyourname.a" to begin with. You don't need Android.mk for that, even though in many cases deriving a standards-compliant Android.mk is trivial, and makes the developer's life happier in the long run (See, e.g., github).

The next step should be to prepare a JNI wrapper dynamic library (shared object, .so), which can be loaded from your Java app. That "libyourname_jni.so" will probably have its own, separate Android.mk file. Well, Java is not a must: you can use NativeActivity, or maybe some alternative frameworks.

I suggest the following reading to understand the whole process: http://thesoftwarerogue.blogspot.co.il/2010/05/porting-of-libcurl-to-android-os-using.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top