Unable to find header files - Android NDK

梦想的初衷 提交于 2019-12-18 11:52:49

问题


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)

include $(call all-subdir-makefiles)

LOCAL_PATH :=/home/marcos/dev/workspace/rmsdk.native.wraper/jni

include $(CLEAR_VARS)

LOCAL_LDLIBS := -llog
LOCAL_MODULE    := ndk1
LOCAL_SRC_FILES := native.c DelegateDRMProcessorClient.cpp
LOCAL_STATIC_LIBRARY := adept cryptopenssl dp expat fonts hobbes jpeg mschema png t3 xml zlib

include $(BUILD_SHARED_LIBRARY)

project/jni/prereqs/

Android.mk (Used to call all subdirs Android.mk files)

LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)

project/jni/prereqs/%lib%/

Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    :=dp
LOCAL_SRC_FILES :=libdp.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include

include $(PREBUILT_STATIC_LIBRARY)

And there's a include folder on each %lib% folder.

When using ndk-build I get a "/home/marcos/dev/workspace/rmsdk.native.wraper/jni/DelegateDRMProcessorClient.h:18:20: error: dp_all.h: No such file or directory"

Anyone knows how to include these header to be available to the compiler?


回答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.




回答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)



回答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



回答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.



来源:https://stackoverflow.com/questions/4594836/unable-to-find-header-files-android-ndk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!