Unable to find header files - Android NDK

后端 未结 4 666
南笙
南笙 2020-12-28 19:17

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

相关标签:
4条回答
  • 2020-12-28 19:52

    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.

    0 讨论(0)
  • 2020-12-28 19:59

    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)
    
    0 讨论(0)
  • 2020-12-28 20:06

    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.

    0 讨论(0)
  • 2020-12-28 20:09

    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
    
    0 讨论(0)
提交回复
热议问题