Game Development Reference
In-Depth Information
Extracting Native Android Libraries
The header libraries from the previous section provide the required files to compile the code. However,
you also need the system image shared libraries for the linking process; that is, you need the *.so files
stored in /system/lib in your device. For example, using the emulator shell, you can take a look at device
file systems and some of the system libraries. Using the Android Debug Bridge ( adb ), connect to the
device, and then run the df command to inspect the device file systems, as shown in the next fragment:
user@ubuntu:~$ adb shell
# df
/dev: 47284K total, 0K used, 47284K available (block size 4096)
/sqlite_stmt_journals: 4096K total, 0K used, 4096K available (block size 4096)
/system: 65536K total, 43496K used, 22040K available (block size 4096)
/data: 65536K total, 43004K used, 22532K available (block size 4096)
/cache: 65536K total, 1156K used, 64380K available (block size 4096)
/sdcard: 40309K total, 34114K used, 6195K available (block size 512)
# ls -l /system/lib
-rw-r--r-- root root 9076 2008-11-20 00:10 libdl.so
-rw-r--r-- root root 227480 2008-11-20 00:10 libc.so
-rw-r--r-- root root 13368 2008-11-20 00:10 libthread_db.so
-rw-r--r-- root root 9220 2008-11-20 00:10 libstdc++.so
-rw-r--r-- root root 140244 2008-11-20 00:10 libm.so
-rw-r--r-- root root 79192 2008-11-20 00:10 libz.so
-rw-r--r-- root root 92572 2008-11-20 00:10 libexpat.so
-rw-r--r-- root root 767020 2008-11-20 00:10 libcrypto.so
-rw-r--r-- root root 155760 2008-11-20 00:10 libssl.so
[Other files...]
The df command displays information about the device file systems. From there, you can inspect
the libraries stored in the device /system/lib folder. The ls command shows the most important
libraries: C runtime ( libc.so ), Math runtime ( libm.so ), Gzip ( libz.so ), XML ( libexpat.so ), and others.
These are the files you need to extract to the local system for the linking step. To extract them, you can
create a simple script and use the emulator tool adb pull command to pull a file from the device to the
local file system.
First, create a folder in your home directory to store these libraries:
$ mkdir -p $HOME/tmp/android/system/lib
$ cd $HOME/tmp/android/system/lib
Next, create a simple script to fetch the files from the device to the $HOME/tmp/android/system/lib
folder. The bash script in Listing 1-1 loops through the library names and pulls the file from the
device /system/lib folder to the local file system current directory.
 
Search WWH ::




Custom Search