Game Development Reference
In-Depth Information
It helps in debugging. In some cases, differences in the C compiler can cause
runtime crashes and many issues that are difficult to debug. For example, the
CodeSourcery G++ compiler used in this topic is at version 4.3.x, while the NDK
compiler is at 4.2.x. This difference can have a significant impact in the way
programs run. As a matter of fact, I had crashes on libraries compiled with
CodeSourcery that work just fine using the NDK. The NDK will ensure your library
is on par with the C runtime running in the device.
All in all, the NDK is a good tool that can be a time saver once you get used to it. Plus, you can add
manual library support to satisfy custom needs. In the next section, you'll learn how to use this tool to
compile Wolf 3D from source.
Installing the Android NDK and Cygwin
Installing the Android NDK is simple. Just download the zip archive and uncompress it somewhere in your
file system. You can get it at http://developer.android.com/sdk/ndk/1.6_r1/index.html .
If you are using a Windows system, you will also need Cygwin, the Linux-like environment for Windows.
Cygwin installation can be a little time consuming but isn't difficult. Simply download the installer, and
follow the easy instructions (make sure you select GNU make under development tools in the package
selection page of the install). You can get the Cygwin installer at http://www.cygwin.com/ .
Tip If using Cygwin, you must install GNU make . This tool is not enabled by default in the Cygwin installation
wizard, and it is required by the Android NDK. Please read the NDK installation instructions under
NDK_HOME/docs/INSTALL.TXT before your proceed!
Compiling Wolf 3D with the NDK 1.5
In this section, you will learn how to use the NDK to compile the native code in Chapter 6 in a Windows
system running Cygwin. Take a look at the NDK folder structure. There are two folders that any
application must use:
app : This folder contains all the modules to be compiled.
sources : This folder contains the code for every module in the app folder.
Let's compile the Wolf3D library using the NDK:
1.
Create an application module folder in NDK_HOME\apps\Wolf3D .
Within the folder above you need to create the folder NDK_HOME\apps\Wolf3D\
project\libs\armeabi . This folder will contain the actual compiled library.
2.
3.
Create the application module descriptor file NDK_HOME\apps\
Wolf3D\Application.mk . This file describes the name of the module as follows:
 
Search WWH ::




Custom Search