views:

78

answers:

1

Hi

I'm new to Android ndk and i didn't understand yet which are the differences between static and shared library. Could you explain me what these differences are? When developing a library how could i choose one of them?

Thanks a lot

+1  A: 

The term shared library is not a perfect fit regarding Android's NDK, because in many cases the .so libraries aren't actually shared between applications. It's better to classify the libraries that the NDK builds as static and dynamic.

Every Android application is a Java application, and the only entry point for the NDK code is loading it as a dynamic library and call it trough JNI.

Static libraries are an archives of compiled object files. They get bundled in other libraries at build time. Unused portions of code from static libraries are stripped by the NDK to reduce total size.

Dynamic libraries are loaded in runtime from separate files. They can contain static libraries that they are dependent on, or load more dynamic libraries.

So what you actually need for Android development is at least one shared library, that will be called from Java code, and linked with it's dependencies as static libraries preferably.

ognian