Game Development Reference
In-Depth Information
FILES := objs.c misc.c id_ca.c id_vh.c id_us.c \
wl_act1.c wl_act2.c wl_act3.c wl_agent.c wl_game.c \
wl_inter.c wl_menu.c wl_play.c wl_state.c wl_text.c wl_main.c \
wl_debug.c vi_comm.c sd_comm.c \
wl_draw.c jni_wolf.c vi_null.c sd_null.c
LOCAL_SRC_FILES := $(FILES)
include $(BUILD_SHARED_LIBRARY)
Let's take a closer look to the variables defined in Listing A-2:
LOCAL_PATH
: This variable defines the local path of the module,
NDK_HOME/sources/Wolf3D
in this particular case.
•
LOCAL_MODULE
: This variable defines the name of the local module. It must match
the module name (
wolf3d
) with the prefix
lib
, thus
libwolf3d
.
•
LOCAL_CFLAGS
: Here is where you can put the optimization flags of your choice and
extra include directories (where C headers live). For Wolf 3D, I use
-Isources/Wolf3D/include
•
LOCAL_SRC_FILES
: These are the source files that compose the library.
The following actions will be executed during the
make
process:
•
include $(CLEAR_VARS)
: This action clears previous values of the local variables
used by the module.
•
include $(BUILD_SHARED_LIBRARY)
: This action tells the compilation project to
build a shared library.
•
Types of libraries in Linux
The types of libraries that can be compiled with the NDK can be confusing for the newcomer:
•
Shared libraries
: These are loaded dynamically by an executable at runtime. In
Linux, they use the naming convention
lib<SOME_NAME>.so
. For example,
libwolf3d.so
is the shared library used by our project.
•
Static libraries
: These are binary code archives that will be included into a master
shared library at compile time. They use the naming convention
lib<SOME_NAME>.a
.
Compiling the Shared Library
Finally, we are ready to go. Start the compilation process by typing the following within the NDK home
folder (see Figure A-5):