gpt4 book ai didi

android - 使用 Android NDK 编译 libharu

转载 作者:行者123 更新时间:2023-11-29 22:21:36 26 4
gpt4 key购买 nike

我正在尝试编译 libharu对于安卓。在我的 jni 文件夹中:

  • /jni/lpng154/ 包含 libpng 的所有源文件和包含文件;
  • /jni/libharu-2.2.1/ 包含 libharu 的所有源代码和包含文件

这是我的 Android.mk(在 /jni/ 文件夹中)。 libharu 与 libpng 有依赖关系,所以我必须先编译 libpng。

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

sources := png.c \
pngerror.c \
pngget.c \
pngmem.c \
pngpread.c \
pngread.c \
pngrio.c \
pngrtran.c \
pngrutil.c \
pngset.c \
pngtrans.c \
pngwio.c \
pngwrite.c \
pngwtran.c \
pngwutil.c

LOCAL_C_INCLUDES := $(LOCAL_PATH)/lpng154
LOCAL_MODULE := png
LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := $(sources:%=lpng154/%)

include $(BUILD_STATIC_LIBRARY)

然后编译libharu。

include $(CLEAR_VARS)

sources := hpdf_annotation.c \
hpdf_array.c \
hpdf_binary.c \
hpdf_boolean.c \
hpdf_catalog.c \
hpdf_destination.c \
hpdf_dict.c \
hpdf_doc.c \
hpdf_doc_png.c \
hpdf_encoder.c \
hpdf_encoder_cns.c \
hpdf_encoder_cnt.c \
hpdf_encoder_jp.c \
hpdf_encoder_kr.c \
hpdf_encrypt.c \
hpdf_encryptdict.c \
hpdf_error.c \
hpdf_ext_gstate.c \
hpdf_font.c \
hpdf_font_cid.c \
hpdf_fontdef_base14.c \
hpdf_fontdef.c \
hpdf_fontdef_cid.c \
hpdf_fontdef_cns.c \
hpdf_fontdef_cnt.c \
hpdf_fontdef_jp.c \
hpdf_fontdef_kr.c \
hpdf_fontdef_tt.c \
hpdf_fontdef_type1.c \
hpdf_font_tt.c \
hpdf_font_type1.c \
hpdf_gstate.c \
hpdf_image.c \
hpdf_image_png.c \
hpdf_info.c \
hpdf_list.c \
hpdf_mmgr.c \
hpdf_name.c \
hpdf_namedict.c \
hpdf_null.c \
hpdf_number.c \
hpdf_objects.c \
hpdf_outline.c \
hpdf_page_label.c \
hpdf_page_operator.c \
hpdf_pages.c \
hpdf_real.c \
hpdf_streams.c \
hpdf_string.c \
hpdf_u3d.c \
hpdf_utils.c \
hpdf_xref.c \
hpdf_pdfa.c

LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/lpng154 \
$(LOCAL_PATH)/libharu-2.2.1/include \
$(LOCAL_PATH)/libharu-2.2.1/src

LOCAL_LDLIBS := -lz -lm
LOCAL_MODULE := haru
LOCAL_SRC_FILES := $(sources:%=libharu-2.2.1/src/%)

LOCAL_STATIC_LIBRARIES := z png

include $(BUILD_SHARED_LIBRARY)

当我运行 ndk-buid 时,编译器在尝试编译文件 *hpdf_image_png.c* 时停止,并出现许多类似的错误:

.../src/hpdf_image_png.c: In function 'ReadPngData_Interlaced':
.../src/hpdf_image_png.c:113: error: dereferencing pointer to incomplete type
.../src/hpdf_image_png.c:118: error: dereferencing pointer to incomplete type
.../src/hpdf_image_png.c:119: error: dereferencing pointer to incomplete type
.../src/hpdf_image_png.c:129: error: dereferencing pointer to incomplete type
...
...

我猜 ndk-build 找不到 png.h ...我怎样才能帮助编译器找到 header ?

如果在我的 Android.mk 中添加标志:

LOCAL_CFLAGS    := -DLIBHPDF_HAVE_NOPNGLIB

前两行:

LOCAL_LDLIBS    := -lz  -lm
LOCAL_MODULE := haru
...

然后运行 ​​ndk-build 一切正常编译...但我会错过 libharu 中的 png 嵌入。

谢谢大家。

最佳答案

在使用 libpng 1.5 编译时,libharu 中存在一个错误。

您可以应用此补丁: https://github.com/tony2001/libharu/commit/e5bf8b01f6c3d5e3fe0e26ac5345e0da10c03934

关于android - 使用 Android NDK 编译 libharu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7040516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com