Marcos Vasconcelos
Marcos Vasconcelos

Reputation: 18276

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)

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?

Upvotes: 13

Views: 41498

Answers (4)

Bisma Saeed
Bisma Saeed

Reputation: 827

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.

Upvotes: 1

Keo Malope
Keo Malope

Reputation: 1015

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

Upvotes: 4

slushduck
slushduck

Reputation: 193

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)

Upvotes: 12

Marcos Vasconcelos
Marcos Vasconcelos

Reputation: 18276

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.

Upvotes: 15

Related Questions