Skip to content Skip to sidebar Skip to footer

Unable To Find Header Files - Android Ndk

i'm wrapping a native API to Android by NDK. But when building it don't find the header files. I have the following structure. project/jni Android.mk LOCAL_PATH := $(call my-dir)

Solution 1:

I solve it, getting all the headers in a folder and including the following line in the Android.mk

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all

This works, but not looks like the best approach.

Solution 2:

I'm a bit late to this party, but ran into the same issue and might have an answer for your comment: "This works, but not looks like the best approach"

There;s a sample in the NDK called "module-exports" It shows how to construct an Android.mk file which respects header files living in their proper directories and not all dumped into a single include directory.

LOCAL_PATH := $(call my-dir)include$(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo/foo.c
LOCAL_CFLAGS := -DFOO=2
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
LOCAL_EXPORT_CFLAGS := -DFOO=1
LOCAL_EXPORT_LDLIBS := -llog
include$(BUILD_STATIC_LIBRARY)include$(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_SRC_FILES := bar/bar.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar
LOCAL_STATIC_LIBRARIES := foo
include$(BUILD_SHARED_LIBRARY)include$(CLEAR_VARS)
LOCAL_MODULE := zoo
LOCAL_SRC_FILES := zoo/zoo.c
LOCAL_SHARED_LIBRARIES := bar
include$(BUILD_SHARED_LIBRARY)

Solution 3:

Years later...

To export the include directory instead of individual files, I use the following:

LOCAL_EXPORT_C_INCLUDE_DIRS  := $(MY_DIRECTORY_PATH)

For example, for the above question the export for "foo" would look like:

LOCAL_EXPORT_C_INCLUDE_DIRS  := $(LOCAL_PATH)/foo

Solution 4:

For new people's convenience, I just want to add that move all your header files in folder which is referred by LOCAL_C_INCLUDES := $(LOCAL_PATH) and then save android.mk and restart eclipse. After trying all the above solutions, that worked for me.

Post a Comment for "Unable To Find Header Files - Android Ndk"