title: Compiling libharu with Android NDK
body: <p>I'm trying to compile <a href="http://libharu.org/wiki/Main_Page" rel="nofollow">libharu</a> for Android. In my <strong>jni</strong> folder I've:</p>
  
  <ul>
  <li><strong>/jni/lpng154/</strong> with all sources and include files for libpng;</li>
  <li><strong>/jni/libharu-2.2.1/</strong> whit all sources and include files for libharu</li>
  </ul>
  
  <p>This is my <i>Android.mk</i> (in <strong>/jni/</strong> folder). libharu has dependencies with libpng so I've to compile libpng first.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>Then for compiling libharu.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>When i run <em>ndk-buid</em> the compiler stops when trying to compile the file *hpdf_image_png.c* following with many errors like those:</p>
  
  <pre><code>.../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
  ...
  ...
  </code></pre>
  
  <p>I guess ndk-build cannot find <em>png.h</em> ...how may I help the compiler to find the header ?</p>
  
  <p>If in my Android.mk I add the flag:</p>
  
  <pre><code>LOCAL_CFLAGS    := -DLIBHPDF_HAVE_NOPNGLIB
  </code></pre>
  
  <p>before the two rows:</p>
  
  <pre><code>LOCAL_LDLIBS    := -lz  -lm
  LOCAL_MODULE    := haru
  ...
  </code></pre>
  
  <p>and run <em>ndk-build</em> everithing compile fine...but I will miss the png embedding in libharu.</p>
  
  <p>Thanks to all of you.</p>