Static libraries, How to build and link them

72 views
Skip to first unread message

jje...@istation.com

unread,
Jul 27, 2015, 4:54:32 PM7/27/15
to android-ndk
Does anyone know of a version of the two libraries example that uses static libraries ?

I'm not little luck getting make files that will build and link-to static libraries.

Can anyone show me how to make that example work with at least one of the libraries static?

jje...@istation.com

unread,
Jul 28, 2015, 10:44:47 AM7/28/15
to android-ndk, jje...@istation.com
For example: 

Say I have c source files in ../jni/mylib

How do I get it to compile as a static library, via ../jni/mylib/Android.mk that is included/linked to from
../jni/Android.mk ?

I've yet to find a sample that show how to do this.  Or another angle, does anyone know how to mod
the two-libs sample such that one of the libs is static?



Simon Taylor

unread,
Jul 28, 2015, 11:04:06 AM7/28/15
to android-ndk, jje...@istation.com
The two-libs sample already has one of the libs as static.

Line 30 makes the "libtwolib-first" module be built as a static library. This is then included as a dependency in the "libtwolib-second" by line 39.

Your "outer" module will need to be shared (native code can only be shipped and loaded as shared libraries). ndk-build will build any top-level shared libraries it can find, and it this case the LOCAL_STATIC_LIBRARIES := libtwolib-first line will ensure the first one is built as a static library first as part of the process of building libtwolib-second.

You'll need to be more specific about your problem for any more help.

Simon
Reply all
Reply to author
Forward
0 new messages