Programming with the dynamic linker library in Android NDK
Dynamic loading is a technique to load a library into memory at runtime, and execute functions or access variables defined in the library. It allows the app to start without these libraries.
We have seen dynamic loading in almost every recipe of this book. When we call the System.loadLibrary
or System.load
function to load the native libraries, we are using dynamic loading.
Android NDK has provided the dynamic linker library to support dynamic loading in NDK, since Android 1.5. This recipe discusses the dynamic linker library functions.
Getting ready...
Readers are expected to know how to create an Android NDK project. You can refer to the Writing a Hello NDK program recipe of Chapter 1, Hello NDK for detailed instructions.
How to do it...
The following steps describe how to create an Android application using the dynamic linking library to load the math library and compute the square root of 2.
Create an Android application named
DynamicLinker...