Tool chain

Building applications for Android/Linux requires the use of a cross-compiler tool chain from CodeSourcery. The specific version required is the Sourcery G++ Lite Edition for ARM, found at http://www.codesourcery.com/gnu_toolchains/arm/portal/ [email protected]=release. Once installed, the Sourcery G++ tool chain contributes a number of useful tools to assist in the creation of applications targeting Linux on ARM, which is the architecture of the Android platform. The ARM platform is a 32-bit reduced instruction set computer (RISC) processor, used in numerous devices including smartphones, PDAs, and technology appliances such as low-end routers and disk drive controllers. The CodeSourcery installation comes with a fairly comprehensive set of PDF documents describing the main components of the tool chain, including the C compiler, the assembler, the linker, and many more tools. A full discussion of these versatile tools is well beyond the scope of this chapter; however, three tools in particular are demonstrated in the construction of this chapter's sample applications. We will be using these tools right away, so we briefly introduce them in this section.

The first and most important tool introduced is gcc. This tool is the compiler responsible for turning C source files into object files and optionally initiating the link process to build an executable suitable for the Android/Linux target platform. The full name of the gcc compiler for our cross-compilation environment is arm-none-linux-gnueabi-gcc. This tool is invoked from the command line of the development machine. The tool takes command-line arguments of one or more source files along with zero or more of the numerous available switches.

The linker, arm-none-linux-gnueabi-ld, is responsible for producing an executable application for our target platform. When performing the link step, object code along with routines from one or more library files are combined into a relocatable, executable binary file, compatible with the Android Emulator's Linux environment. While a simple application may be compiled and linked directly with gcc, the linker is used when creating applications with more than one source file and/or more complex application requirements.

If the linker is responsible for constructing applications from more than one contributing component, the object dump utility is useful for dissecting, or disassembling, an application. We introduce the objdump, or arm-none-linux-gnueabi-objdump, tool presently; its usefulness becomes more apparent later in the chapter. This utility examines an executable application—a binary file—and turns the machine instructions found there into an assembly language listing file, suitable for analysis.

NOTE: All of the examples in this chapter take place on a Windows XP workstation. It is also possible to use this tool chain on a Linux development machine.

With this brief introduction behind us, let's build the obligatory Hello Android application to run in the Linux foundation of the Android Emulator.

0 0

Post a comment