There are many C/C++ libraries for the Desktop computing world. These libraries can save us a huge amount of effort if we can reuse them on an Android platform. Android NDK makes this possible. In this chapter, we will discuss how to port the existing libraries to Android with NDK.
We will first introduce how to build libraries with the Android NDK build system. We can build a library as a static library module or a shared library module. The differences between the two will be discussed in this chapter.
We can also use the Android NDK toolchain as a standalone cross compiler, which is covered next. We will then describe how to use the compiled libraries as prebuilt modules.
We often use the same library in multiple Android projects. We can use the import-module feature to link to the same library module to multiple projects while maintaining a single copy of the library.