NDK编译
开始一直还天真的以为在桌面下编好的/usr/local/libhpdf.so可以直接用,后来才意识到要用NDK重新编~.~
步骤:
项目路径/jni下有两个文件夹:
libharu 和 lpng163 其中包含了 所有对应的src 和 include文件
还有haru 自带的例子 font_demo.cpp
针对: lpng163
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 \
pngtest.c \
pngwio.c \
pngwrite.c \
pngwtran.c \
pngwutil.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/lpng163
LOCAL_MODULE := png
LOCAL_LDLIBS := -lz
LOCAL_SRC_FILES := $(sources:%=lpng163/%)
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_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
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/libharu/include \
$(LOCAL_PATH)/libharu/src \
$(LOCAL_PATH)/lpng163
LOCAL_LDLIBS := -lz -lm
LOCAL_MODULE := haru
LOCAL_SRC_FILES := $(sources:%=libharu/src/%)
LOCAL_STATIC_LIBRARIES := z png
include $(BUILD_SHARED_LIBRARY)
最后就是font_demo了
include $(CLEAR_VARS) LOCAL_MODULE := haru_font LOCAL_SRC_FILES := font_demo.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/libharu/include LOCAL_CPPFLAGS += -fexceptions LOCAL_STATIC_LIBRARIES := z png haru include $(BUILD_SHARED_LIBRARY)
如果只是这样,会报错
error: dereferencing pointer to incomplete type
需要
1) 缺少 pnglibconf.h ,这个文件在png/scripts/pnglibconf.h.prebuilt ,拷贝出来,改名为pnglibconf.h
2)增加 hpdf_image_png.c 的头文件, 在#include <png.h> 后增加
#include <pngstruct.h>
#include <pnginfo.h>
即可成功!
使用NDK重新编译libharu和png库
本文详细介绍了如何使用NDK重新编译libharu和png库,包括具体步骤、解决编译错误的方法以及相关依赖库的配置。
932

被折叠的 条评论
为什么被折叠?



