linux - "/usr/bin/ld: cannot find -lz"

标签 linux gcc linker

我正在尝试在 Ubuntu 10.04 下编译 Android 源代码。我收到一条错误消息,

/usr/bin/ld: cannot find -lz

你能告诉我如何解决它吗? cannot find -lz 是什么意思?以下是完整的错误信息:

external/qemu/Makefile.android:1101: warning: overriding commands for target `external/qemu/android/avd/hw-config-defs.h'
external/qemu/Makefile.android:933: warning: ignoring old commands for target `external/qemu/android/avd/hw-config-defs.h'
host SharedLib: libneo_cgi (out/host/linux-x86/obj/lib/libneo_cgi.so)
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.a when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.so when searching for -lz
/usr/bin/ld: skipping incompatible /usr/lib/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [out/host/linux-x86/obj/lib/libneo_cgi.so] Error 1

还有我的 GCC 版本输出:

scheung@scheung-virtual-box:/media/EXTDIV/mydroid$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我已经安装了 zlib1g-dev 库:

$ sudo apt-get install zlib1g-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
zlib1g-dev is already the newest version.

(我从 this link 得到。)

最佳答案

我遇到了完全相同的错误,和你一样,安装 zlib1g-dev 并没有修复它。安装 lib32z1-dev 让我通过了它。我有一个 64 位系统,它似乎想要 32 位库。

关于linux - "/usr/bin/ld: cannot find -lz",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3373995/

相关文章:

python - 在 CentOS 7 上使用 Tensorflow 的零星核心转储(段错误、非法指令)

linux - 如何检查字符串是否以特定字符串开头>

c++ - Bash 自动完成选项而不运行应用程序

c - 使用 typeof 编译器扩展在 C 中实现 min 函数会出现错误

c++ - 如何在 Android NDK GCC 上使用 AddressSanitizer?

c - 为什么仅在将变量传递给 '-lm' 函数时才显式使用 'math.h'?

windows - MinGW 创建 dll.a 文件?这些是什么类型的库文件?

linux - xmessage 长文本 - 换行?

c - 彩色的 printf 语句

ubuntu - 以普通用户身份选择替代库