正如这个答案中所指定的,我从 github 下载了 libjpeg 8d 并将其放在一个文件夹{ANDROID_APP}/jni/libjpeg
中。这个库有它自己的Android.mk
,所以我试图在我的最后包含它{ANDROID_APP}/jni/Android.mk
:
include $(LOCAL_PATH)/libjpeg/Android.mk
注意:我使用的是最新版本的 android NDK (r8c)
运行 ndk-build 后,我仍然收到此错误:
ANDROID_APP/jni/libfoo/foo_analysis.c:36:21: fatal error: jpeglib.h: No such file or directory
这是我的全局结构Android.mk
:
LOCAL_PATH := $(call my-dir)
# libFoo
include $(CLEAR_VARS)
LOCAL_MODULE := libfoo
LOCAL_MODULE_FILENAME := libfoo
LOCAL_SRC_FILES := libfoo/foo.c libfoo/foo_analysis.c libfoo/foo_extract.c
LOCAL_STATIC_LIBRARIES := libbmp # declared previously but not shown in this example
LOCAL_CFLAGS = ${FLAGS}
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libfoo
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
# libBar
include $(CLEAR_VARS)
LOCAL_MODULE := libbar
LOCAL_MODULE_FILENAME := libbar
LOCAL_SRC_FILES := bar/bar.c
LOCAL_STATIC_LIBRARIES := libfoo
LOCAL_CFLAGS = ${FLAGS}
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
# callbar
LOCAL_MODULE := libcallbar
LOCAL_MODULE_FILENAME := libcallbar
LOCAL_SRC_FILES := com_androidapp_nativeC_callbar.c
LOCAL_STATIC_LIBRARIES := libbar
LOCAL_CFLAGS = ${FLAGS}
include $(BUILD_SHARED_LIBRARY)
#libjpeg
include $(LOCAL_PATH)/libjpeg/Android.mk
我尝试在 libFoo 模块中使用LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libfoo $(LOCAL_PATH)/libjpeg
and LOCAL_C_INCLUDES := $(LOCAL_PATH)/libjpeg
,但仍然遇到相同的错误。