问题描述
我的交流源文件夹名为"clib",在该文件夹中,我有一些示例文件,例如1.h,1.c,2.h,2.c,3.c,3.h,在该文件夹之外我有4.h,4.c,4_jni.h,4_jni.c
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
现在要构建".so",我创建了这样的android.mk
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)
此处4.h包含1.h文件
所以我真正的问题是当我尝试构建.so文件时,它给了我这样的错误
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
fatal error: 1.h: No such file or directory
如果我从4.h中删除1.h,一切都很好,但是我有一个很大的c库具有相同的文件夹结构,并且.h文件中的一些包含很少定义的marcos ....
if i remove the 1.h from 4.h , everything is building fine , but i had a large c librarywith same kind of folder structure , and some of .h file contains few marcos defined ....
因此,请提出任何建议如何在不同的文件夹中包含.h.
So Please any suggestion how to include .h which is in different folder..
推荐答案
您需要指定LOCAL_C_INCLUDES
位置.
此变量保存您的头文件的位置,例如:
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/
请注意,当使用ndk-build
实用程序评估此变量时,其值被认为是相对于$(LOCAL_PATH)
的,因此在LOCAL_C_INCLUDES
中给出路径时需要使用$(LOCAL_PATH)
.
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
.
这篇关于如何在android.mk文件中指定C头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!