Game Development Reference
In-Depth Information
# Cleanup
clean:
rm *.o
#
# Push binary into device
#
pushbin:
adb push a.out /data
# Push lib & test program to the device
pushlib:
adb push testlib /data
adb push libch02.so /data
Type
make lib
to compile the library (see Listing 2-7). Note that the Makefile uses the
agcc
and
ald
scripts created in the previous chapter. Other interesting aspects of the process include the following:
CFLAGS=-Werror
: This tells the compiler to abort whenever there is a warning in the
compilation process. This can be a powerful debugging tool to find programming
errors within your code.
•
javah -jni -classpath ../bin -d include jni.Natives
: This creates the C
header file for the native methods in the
jni.Natives
class. Output is saved in the
include folder.
•
adb push FILENAME DEVICE_DEST
: This is the Android SDK command to upload a
file to a specific location in the device.
•
Listing 2-7.
Makefile Output
user@ubuntu:~/ ch02.Project/native$ make lib
Compiling lib.c...
agcc -c lib.c
Linking Shared library...
ald -shared -o libch02.so lib.o
arm-none-linux-gnueabi-ld: warning: library search path "/usr/lib/jvm/java-6-
sun/jre/lib/i386" is unsafe for cross-compilation
Copying Shared library to assets folder
cp libch02.so ../assets
Compiling testlib.c...
agcc -c testlib.c
Linking Test for Shared library
ald -o testlib testlib.o -L. -lch02