- Android NDK Game Development Cookbook
- Sergey Kosarevsky Viktor Latypov
- 239字
- 2021-07-21 18:21:23
Linking and source code organization
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.
Getting ready
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.
How to do it...
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.
How it works...
All of our examples from the subsequent chapters are buildable for Windows from the command line using a single make all
command. Android native code is buildable with a single ndk-build
command. We will use this convention throughout the rest of the book.
- 用“芯”探核:龍芯派開發實戰
- Learning AngularJS Animations
- 龍芯應用開發標準教程
- 計算機組裝與系統配置
- 施耐德SoMachine控制器應用及編程指南
- 嵌入式系統中的模擬電路設計
- 計算機組裝與維修技術
- 固態存儲:原理、架構與數據安全
- OpenGL Game Development By Example
- Source SDK Game Development Essentials
- Internet of Things Projects with ESP32
- 基于PROTEUS的電路設計、仿真與制板
- Istio服務網格技術解析與實踐
- 新編電腦組裝與硬件維修從入門到精通
- MicroPython Cookbook