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

时间:2022-02-21 15:07:38

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.

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

Compiling environment:

编译环境:

    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

The following is the configure command for setting up compiling environment for libcurl:

下面是为libcurl设置编译环境的配置命令:

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"

after executing the config command, I can see following content from the config.log file under external/curl directory that

执行配置命令后,我可以从配置中看到以下内容。在外部/curl目录下的日志文件。

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

I also checked the directory : $NDK_HOME/platforms/android-14/arch-arm/usr/include and make sure zlib.h file does exist there.

我还检查了目录:$NDK_HOME/平台/android-14/ archarm /usr/包括并确保zlib。h文件确实存在。

Problem: when I tried to compile libcurl using commands make libcurl, the compliation fails. And the error I got is:

问题:当我试图使用命令来编译libcurl时,遵从性就会失败。我得到的错误是:

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'

It really makes me upset since the file does exist and found at the configuration step.

因为文件确实存在,并且在配置步骤中找到,所以我很沮丧。

Solution attempt: 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.

解决方案尝试:我尝试添加zlib的绝对路径。h文件在NDK_HOME到Android。位于外部/curl目录的mkfile,如下所示。

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

It turns out the errors are gone and compliation is successful, but when using the curl library in the program, the following error happens:

结果表明,错误已经消失,遵从性是成功的,但是当在程序中使用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_'

Anyone has the same problem? Any help is greatly appreciated.

有人有同样的问题吗?非常感谢您的帮助。

1 个解决方案

#1


0  

Looks like you are missing -lz when building your program.

看起来你在构建程序时缺少了-lz。

#1


0  

Looks like you are missing -lz when building your program.

看起来你在构建程序时缺少了-lz。