title: Error when compiling LibCurl under Ubuntu: zlib.h : no such file or directory
body: <p>I am trying to compile curl source code (version 7.22.0)under ubuntu 13.04 to import libcurl to Android platform. The Android source code (version Android-2.2_r1) has been already compiled successfully and environment for compiling curl has been set up successfully. </p>
  
  <p>Compiling environment:</p>
  
  <pre><code>    Android Source Code version: 2.2_r1
      NDK Version:android-ndk-r8e
      Curl Souce Code version:7.22.0
      GCC version:4.4.7
      JDK version:1.5.0_21
  </code></pre>
  
  <p>The following is the configure command for setting up compiling environment for libcurl:</p>
  
  <pre><code>ANDROID_HOME=/home/kevin/Android-Build/working-space &amp;&amp; \
  NDK_HOME=/home/kevin/Software/android-ndk-r8e &amp;&amp; \
  PATH="$ANDROID_HOME/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH" \
  ./configure --host=arm-linux CC=arm-eabi-gcc --with-random=/dev/urandom \
  CPPFLAGS="-I$NDK_HOME/platforms/android-14/arch-arm/usr/include \
  -I $ANDROID_HOME/external/curl/include/  \
  -I $ANDROID_HOME/external/curl   \
  -I $ANDROID_HOME/out/target/product/generic/obj/STATIC_LIBRARIES/libcurl_intermediates   \
  -I $ANDROID_HOME/dalvik/libnativehelper/include/nativehelper   \
  -I $ANDROID_HOME/system/core/include   \
  -I $ANDROID_HOME/hardware/libhardware/include   \
  -I $ANDROID_HOME/hardware/libhardware_legacy/include   \
  -I $ANDROID_HOME/hardware/ril/include   \
  -I $ANDROID_HOME/dalvik/libnativehelper/include   \
  -I $ANDROID_HOME/frameworks/base/include   \
  -I $ANDROID_HOME/frameworks/base/opengl/include   \
  -I $ANDROID_HOME/frameworks/base/native/include   \
  -I $ANDROID_HOME/external/skia/include   \
  -I $ANDROID_HOME/out/target/product/generic/obj/include   \
  -I $ANDROID_HOME/bionic/libc/arch-arm/include   \
  -I $ANDROID_HOME/bionic/libc/include   \
  -I $ANDROID_HOME/bionic/libstdc++/include   \
  -I $ANDROID_HOME/bionic/libc/kernel/common   \
  -I $ANDROID_HOME/bionic/libc/kernel/arch-arm   \
  -I $ANDROID_HOME/bionic/libm/include   \
  -I $ANDROID_HOME/bionic/libm/include/arch/arm   \
  -I $ANDROID_HOME/bionic/libthread_db/include \
  -include $ANDROID_HOME/system/core/include/arch/linux-arm/AndroidConfig.h \
  -I $ANDROID_HOME/system/core/include/arch/linux-arm/ \
  -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID -DNDEBUG -DNDEBUG -DHAVE_CONFIG_H" \
  CFLAGS="-fno-exceptions -Wno-multichar -msoft-float -fpic -ffunction-sections \
  -funwind-tables -fstack-protector -Wa,--noexecstack -Werror=format-security \
  -fno-short-enums -march=armv5te -mtune=xscale  -Wno-psabi -mthumb-interwork  \
  -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith \
  -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point  \
  -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once \
  -fgcse-after-reload -frerun-cse-after-loop -frename-registers  -UDEBUG \
  -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64   \
  -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs \
  -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal \
  -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels \
  -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers"  \
  LIBS="-nostdlib -Bdynamic -Wl,-T,$ANDROID_HOME/build/core/armelf.x \
  -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc \
  -L$ANDROID_HOME/out/target/product/generic/obj/lib -Wl,-z,noexecstack \
  -Wl,-rpath-link=$ANDROID_HOME/out/target/product/generic/obj/lib \
  -lc -llog -lcutils -lstdc++ \
  -Wl,--no-undefined $ANDROID_HOME/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/lib/gcc/arm-eabi/4.4.0/libgcc.a  \
   $ANDROID_HOME/out/target/product/generic/obj/lib/crtend_android.o \
  -lm $ANDROID_HOME/out/target/product/generic/obj/lib/crtbegin_dynamic.o"
  </code></pre>
  
  <p>after executing the config command, I can see following content from the config.log file under external/curl directory that </p>
  
  <pre><code>configure:21303: checking zlib.h usability
  configure:21303: $? = 0
  configure:21303: result: yes
  
  configure:21303: checking zlib.h presence
  configure:21303: $? = 0
  configure:21303: result: yes
  
  configure:21303: checking for zlib.h
  configure:21303: result: yes
  configure:21384: found both libz and libz.h header
  </code></pre>
  
  <p>I also checked the directory : <code>$NDK_HOME/platforms/android-14/arch-arm/usr/include</code> and make sure zlib.h file does exist there.</p>
  
  <p><strong>Problem</strong>: when I tried to compile libcurl using commands <code>make libcurl</code>, the compliation fails. And the error I got is:</p>
  
  <pre><code>In file included from external/curl/lib/base64.c:30:
  external/curl/lib/urldata.h:141:59: error: zlib.h: No such file or directory
  In file included from external/curl/lib/base64.c:30:
  external/curl/lib/urldata.h:585: error: expected specifier-qualifier-list before 'z_stream'
  </code></pre>
  
  <p>It really makes me upset since the file does exist and found at the configuration step.</p>
  
  <p><strong>Solution attempt:</strong>
  I tried to add the absolute path of zlib.h file in NDK_HOME to Android.mk file which locates at external/curl directory like the following.</p>
  
  <pre><code>LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ /home/kevin/Software/android-ndk-r8e/platforms/android-14/arch-arm/usr/include 
  </code></pre>
  
  <p>It turns out the errors are gone and compliation is successful, but when using the curl library in the program, the following error happens:</p>
  
  <pre><code>/home/kevin/Software/android-ndk-r8e/platforms/android-14/arch-arm/usr/lib/libcurl.a(content_encoding.o): in function Curl_unencode_deflate_write:external/curl/lib/content_encoding.c:180: error: undefined reference to 'inflateInit_'
  </code></pre>
  
  <p>Anyone has the same problem? Any help is greatly appreciated.</p>