在Ubuntu下编译LibCurl时出错:zlib.h:没有这样的文件或目录

时间:2013-07-11 03:15:25

标签: android curl compilation android-ndk header-files

我正在尝试在ubuntu 13.04下编译curl源代码(版本7.22.0)以将libcurl导入Android平台。 Android源代码(版本为Android-2.2_r1)已经成功编译,并且已经成功设置了编译curl的环境。

编译环境:

    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

以下是用于为libcurl设置编译环境的configure命令:

ANDROID_HOME=/home/kevin/Android-Build/working-space && \
NDK_HOME=/home/kevin/Software/android-ndk-r8e && \
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"

执行config命令后,我可以在external / curl目录下的config.log文件中看到以下内容

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

我还检查了目录:$NDK_HOME/platforms/android-14/arch-arm/usr/include并确保zlib.h文件确实存在。

问题:当我尝试使用命令make libcurl编译libcurl时,compliation失败。我得到的错误是:

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'

由于文件确实存在并且在配置步骤中找到,这确实让我感到不安。

解决方案尝试: 我试图将NDK_HOME中zlib.h文件的绝对路径添加到Android.mk文件中,该文件位于external / curl目录下,如下所示。

LOCAL_C_INCLUDES += $(LOCAL_PATH)/include/ /home/kevin/Software/android-ndk-r8e/platforms/android-14/arch-arm/usr/include 

事实证明错误已经消失并且补偿成功,但是当在程序中使用curl库时,会发生以下错误:

/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_'

任何人都有同样的问题?非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

在构建程序时,您似乎缺少-lz。