In the previous recipes, we learned how to create basic wrappers that allow us to run our application on Android and Windows. However, we used an ad-hoc approach since the amount of source code was low and fit into a single file. We have to organize our project source files in a way suitable for building the code for larger projects in Windows and Android.
Recall the folder structure of the App3
project. We have the src
and jni
folders inside our App2
folder. The jni/Android.mk
, jni/Application.mk
, and build.xml
files specify the Android build process. To enable the Windows executable creation, we add a file named Makefile
, which references the main.cpp
file.
The following is the content of Makefile
:
CC = gcc all: $(CC) -o main.exe main.cpp -lgdi32 -lstdc++
The idea is that when we add more and more OS-independent logic, the code resides in .cpp
files, which do not reference any OS-specific headers or libraries. For the first few chapters, this simple framework that delegates frame rendering and event handling to portable OS-independent functions (OnDrawFrame()
, OnKeyUp()
and so on) is enough.