Chapter 8. Porting and Using the Existing Libraries with Android NDK

In this chapter, we will cover the following recipes:

  • Porting a library as a shared library module with the Android NDK build system
  • Porting a library as a static library module with the Android NDK build system
  • Porting a library with its existing build system using the Android NDK toolchain
  • Using a library as a prebuilt library
  • Using a library in multiple projects with import-module
  • Porting a library that requires RTTI, exception, and STL support

Introduction

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.

Many C++ libraries require STL, C++ exceptions, and Run-Time Type Information (RTTI) supports, which are not available with the Android default C++ runtime library. We will illustrate how to enable these supports by using the popular boost library as an example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset