在NDK版本中包含libjpeg

时间:2012-11-22 16:26:27

标签: android android-ndk libjpeg

正如this answer中所述,我从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

我尝试使用LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/libfoo $(LOCAL_PATH)/libjpeg 和libFoo模块中的LOCAL_C_INCLUDES := $(LOCAL_PATH)/libjpeg,但我仍然得到同样的错误。

1 个答案:

答案 0 :(得分:2)

刚看了jpeg8d-master文件夹中的Android.mk,好像什么都没有。

我试图根据STANDALONE-TOOLCHAIN.HTML直接编译库

我接下来:$ export NDKROOT = / home / alex / tools / android-ndk-r8c(你的NDK在哪里)$ export SYSROOT = $ NDKROOT / platforms / android-9 / arch-arm(或任何其他android平台)

但是来自jpeg8d-master的文件有windows \ r \ n符号,我删除了config.guess,config.sub,depcomp而不是使用$ automake -a命令。并从glib-2.34.0替换ltmain.sh

比$。/ configure CC =“$ NDKROOT / toolchains / arm-linux-androideabi-4.4.3 / prebuilt / linux-x86 / bin / arm-linux-androideabi-gcc --sysroot = $ SYSROOT” - host = arm-linux-androideabi $ make

接下来尝试prebuilts功能NDK - How to use a generated .so library in another project和NDK / PREBUILTS.HTML