How to specify header file c in android.mk file

I had the name of the AC source folder "clib", and in this case I have some example files, such as 1.h, 1.c, 2.h, 2.c, 3.c, 3.h and out of this folder I have 4.h, 4.c, 4_jni.h, 4_jni.c

Now, to build ".so", I created my android.mk file, 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 create the .so file, it gives me an error like this

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

if I remove 1.h from 4.h, everything builds fine, but I had a large c library with the same folder structure, and some of the .h files contain several marks defined ....

So, please, any suggestion for including .h, which is in another folder.

+6
source share
1 answer

You need to specify the location of LOCAL_C_INCLUDES .

This variable contains the locations of your header files, for example:

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

Of course, you can specify several locations:

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

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

+9
source

Source: https://habr.com/ru/post/944179/


All Articles