7

i had a c source folder name "clib" and in that , i have some example files like 1.h ,1.c , 2.h ,2.c,3.c,3.h and out side that folder i have 4.h , 4.c , 4_jni.h , 4_jni.c

Now to build ".so" i created my android.mk something like this

LOCAL_PATH := $(call my-dir) 
MY_PATH := $(LOCAL_PATH) 
include $(call all-subdir-makefiles) 
include $(CLEAR_VARS) 
LOCAL_PATH := $(MY_PATH) 
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_MODULE := clib
TIME_SYNC_PATH := ../../../clib
LOCAL_SRC_FILES := \ 
                    4_jni.c \
                    4.c     \
                    $(TIME_SYNC_PATH)/1.c \
                    $(TIME_SYNC_PATH)/2.c \
                    $(TIME_SYNC_PATH)/3.c \
$(BUILD_SHARED_LIBRARY)

Here 4.h includes 1.h file

So my real problem is when i tried to build .so file it gives me a error some like this

fatal error: 1.h: No such file or directory

if i remove the 1.h from 4.h , everything is building fine , but i had a large c library with same kind of folder structure , and some of .h file contains few marcos defined ....

So Please any suggestion how to include .h which is in different folder..

Naruto
  • 245
  • 1
  • 6
  • 13

1 Answers1

17

You need to specify a LOCAL_C_INCLUDES location.

This variable holds the locations of your header files like :

LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/include/

You can of course specify multiple locations :

LOCAL_C_INCLUDES := $(LOCAL_PATH)/src/include/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/project2/src/include/

Note that when this variable is evaluated by the ndk-build utility, its value is considered to be relative to $(LOCAL_PATH), so you need to use $(LOCAL_PATH) when giving a path in LOCAL_C_INCLUDES.

Halim Qarroum
  • 13,985
  • 4
  • 46
  • 71