当前位置: 代码迷 >> Android >> 移栽libharu至android
  详细解决方案

移栽libharu至android

热度:1   发布时间:2016-04-28 08:10:00.0
移植libharu至android

?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.cLOCAL_C_INCLUDES := $(LOCAL_PATH)/lpng163LOCAL_MODULE     := pngLOCAL_LDLIBS     := -lzLOCAL_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  -lmLOCAL_MODULE    := haruLOCAL_SRC_FILES := $(sources:%=libharu/src/%)LOCAL_STATIC_LIBRARIES := z pnginclude $(BUILD_SHARED_LIBRARY)

?

?

最后就是font_demo了

?

?

include $(CLEAR_VARS) LOCAL_MODULE    := haru_fontLOCAL_SRC_FILES := font_demo.cppLOCAL_C_INCLUDES :=  $(LOCAL_PATH)/libharu/includeLOCAL_CPPFLAGS += -fexceptionsLOCAL_STATIC_LIBRARIES := z png haruinclude $(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>

?

即可成功!

?

  相关解决方案