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..
Most standard headers are stored in /usr/include . It looks like stdbool. h is stored somewhere else, and depends on which compiler you are using. For example, g++ stores it in /usr/include/c++/4.7.
The Android.mk file resides in a subdirectory of your project's jni/ directory, and describes your sources and shared libraries to the build system. It is really a tiny GNU makefile fragment that the build system parses once or more.
Note: We can't include the same header file twice in any program. Create your own Header File: Instead of writing a large and complex code, we can create your own header files and include them in our program to use it whenever we want.
A header file is a file with extension . h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With