Add Include Folders to Android Makefile
Contents
In Android jni folder, we will always add some C/C++ header file folders. Basically, there are two ways to do this job.
Option 1:
Add one of the following lines to your Android.mk inside a module of your choice:
LOCAL_C_INCLUDES := /path/to/your/includes # ignore previous includes # OR LOCAL_C_INCLUDES += /path/to/your/includes # preserve previous includes
If necessary you could create an environment variable pointing at ‘/path/to/your/includes’ and include it like this:
LOCAL_C_INCLUDES := $(MYLIB_INCLUDES_PATH) # ignore previous includes # OR LOCAL_C_INCLUDES += $(MYLIB_INCLUDES_PATH) # preserve previous includes
If you write following code but there is no effect:
LOCAL_C_INCLUDES := ../example/include LOCAL_C_INCLUDES += ../example/include2
please add $(LOCAL_PATH) to them, which will be:
LOCAL_C_INCLUDES := $(LOCAL_PATH)../example/include LOCAL_C_INCLUDES += $(LOCAL_PATH)../example/include2
Option 2:
-
Copy the complete folder with all header-files in it (mylib) into the ‘jni’ folder of your project.
-
Add the following line to your Android.mk inside a module of your choice:
LOCAL_C_INCLUDES := $(LOCAL_PATH)/mylib
or
LOCAL_C_INCLUDES += $(LOCAL_PATH)/mylib
Depending on whether there are previous includes or not. If the include is the first one, use the first examle which use := as keyword. If has previous includes, use latter which is += as keyword.
Author Watterry
LastMod 2015-05-06