Game Development Reference
In-Depth Information
lib: $(MAIN_OBJS) # jni
@echo
$(LINKER) -shared -o $(LIB) $(MAIN_OBJS) $(LIBS)
@echo Done. Out file is $(LIB)
# Create JNI headers
jni:
@echo "Creating JNI C headers..."
javah -jni -classpath ../bin -d include opengl.jni.Natives
# Test dynamic exe
dyn:
$(CC) -c test.c $(INCLUDES)
$(LINKER) -o $(DYN) test.o -lgltest_jni -L.
@echo
@echo Done. Out file is $(DYN)
@echo
.c.o:
@echo
$(CC) -Wall -O2 -fpic -c $(CFLAGS) $(INCLUDES) $<
# Deploy lib to device /data folder
deploy-test:
@echo "Deploying $(LIB) to /data"
adb push $(LIB) /data
clean:
rm -f *.o
First, generate the JNI headers for opengl.jni.Natives.java with the following:
$ make jni
Next, compile the library with the following:
user@ubuntu:~/workspace/ch05.OpenGL/native$ make
agcc -Wall -O2 -fpic -c -DNORMALUNIX -DLINUX -DANDROID -
I/home/user/mydroid/frameworks/base/opengl/include cuberenderer.c
agcc -Wall -O2 -fpic -c -DNORMALUNIX -DLINUX -DANDROID -
I/home/user/mydroid/frameworks/base/opengl/include cube.c
ald -shared -o libgltest_jni.so cuberenderer.o cube.o -lGLES_CM -lui
arm-none-linux-gnueabi-ld: warning: library search path "/usr/lib/jvm/java-6-
sun/jre/lib/i386" is unsafe for cross-compilation
Search WWH ::




Custom Search