【转】“/usr/bin/ld: cannot find -lz”

原文网址:http://stackoverflow.com/questions/3373995/usr-bin-ld-cannot-find-lz

I am trying to compile Android source code under Ubuntu 10.04. I get an error saying,

/usr/bin/ld: cannot find -lz
Can you please tell me how can I fix it? What does cannot find -lz mean? Here‘s the full error message:

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
And my GCC version output:

[email protected]:/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.
I already have the zlib1g-dev library installed:

$ sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
(I get that from this link.)

linux gcc linker
shareimprove this question
edited Oct 22 ‘12 at 22:31

Kazark
2,81532152
asked Jul 30 ‘10 at 17:34

michael
15.4k47146227
7
Wow, really? Even though he specifically says less than 4 inches above your comment that he does have it installed? – Justin Buser May 8 ‘12 at 14:32
4
@Justin Buser it‘s obligatory for every stackoverflow question to include a comment that shows that someone read about one sentence of the question and moved on. – magnetar Jun 10 ‘12 at 13:24
3
@magnetar Ahhh... that must have been at the end of the FAQ, I didn‘t actually read the whole thing unfortunately. ;) – Justin Buser Jul 15 ‘12 at 15:10
add a comment
9 Answers
activeoldestvotes
up vote
67
down vote
I had the exact same error, and like you, installing zlib1g-dev did not fix it. Installing lib32z1-dev got me past it. I have a 64 bit system and it seems like it wanted the 32 bit library.

shareimprove this answer
answered Apr 22 ‘11 at 16:34

kylefinn
96358
5
It worked here with libz-dev (virtual package for zlib1g-dev) on Kubuntu 12.04 x64. – Qsiris Jan 22 ‘13 at 16:06
1
helped me on a totally different problem. Thanks :-) – mgjk Dec 25 ‘13 at 16:20

This should be the accepted answer – Speccy Mar 23 ‘14 at 19:45
1
Also helped me install/build lxml-3.4.0 for Python via pip on Ubuntu 14.04 LTS/trusty. Thanks! – Marian Sep 15 ‘14 at 8:07

sudo apt-get install lib32z1-dev #FTW – Sangharsh Dec 11 ‘14 at 17:51
add a comment

up vote
18
down vote
I just encountered this problem and contrary to the accepted solution of "your make files are broken" and "host includes should never be included in a cross compile"

The android build includes many host executables used by the SDK to build an android app. In my case the make stopped while building zipalign, which is used to optimize and apk before installing on an android device.

Installing lib32z1-dev solved my problem, under Ubuntu you can install it with the following command:

sudo apt-get install lib32z1-dev
shareimprove this answer
edited Nov 22 ‘13 at 13:47

Chilledrat
2,27621427
answered May 1 ‘11 at 19:58

Adam
18112
add a comment
up vote
6
down vote
For x64 just install zlib1g-dev.

sudo apt-get install zlib1g-dev
I don‘t need all the x86 libs ;)

时间: 2024-10-24 13:57:54

【转】“/usr/bin/ld: cannot find -lz”的相关文章

/usr/bin/ld: cannot find -lz

同事在一台机器上新安装的CentOS,我拷贝一个项目在上面编译,老是报如下错误: “/usr/bin/ld: cannot find -lz” 说明:libz.so是有的,在/lib64下面 我设置环境变量LD_LIBRARY_PATH或者使用-L/lib64都不管用,最后使用的方法是在/usr/lib64下面建立一个软连接ln -fs /lib64/libz.so.1.2.3 /usr/lib64/libz.so

Android error: "/usr/bin/ld: cannot find -lz"

Android编译的时候出现错误: /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status 解决: sudo apt-get install zlib1g-dev 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 下列[新]软件包将被安装: zlib1g-dev 升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级. 需要下载 162kB 的软

/usr/bin/ld: cannot find -lstdc++ -lz问题

问题1,/usr/bin/ld: cannot find -lstdc++ 解决方法:yum install libstdc++-static.x86_64 问题2,/usr/bin/ld: cannot find -lz 解决方法:yum install zlib-static.x86_64 之前尝试过安装stdc++和zlib的其他非static库,但都没有解决问题: 原文地址:https://www.cnblogs.com/guoliushui/p/9525088.html

Android 编译错误/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../

编译时出现/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when searching for -lz错误 ============================================ PLATFORM_VERSION_CODENAME=AOSP PLATFORM_VERSION=AOSP TARGET_PRODUCT=generic TARGET_BUIL

chkrootkit 编译报错的解决/usr/bin/ld: cannot find -lc

1:Centos6.5安装chkrootkit wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz tar xvf chkrootkit.tar.gz cd chkrootkit-0.51/ make sense报错如下: /usr/bin/ld: cannot find -lc collect2: ld returned 1 exit status make: *** [strings-static] Error 1 2:解决

关于/usr/bin/ld: cannot find -lcrypto 的错误

Linux下 build code 时,要做 -lssl, -lcrypto 的链接,出现类似下面的错误: /usr/bin/ld: cannot find -lcrypto /usr/bin/ld: cannot find -lssl 原因是没有找到 libssl.so yum info openssl,发现openssl 1.0.0已经安装了 ll /usr/lib64/libssl*,得到 -rwxr-xr-x. 1 root root 242112 Jul 17 2012 /usr/li

【转】关于usr/bin/ld: cannot find -lxxx问题总结

原文网址:http://eminzhang.blog.51cto.com/5292425/1285705 /usr/bin/ld: cannot find -lxxx问题总结 linux下编译应用程序常常会出现如下错误: /usr/bin/ld: cannot find -lxxx 意思是编译过程找不到对应库文件.其中,-lxxx表示链接库文件 libxxx.so. 注:有时候,由于库文件是编译过程临时生成的,如果前面出错也会导致出现这种情况,下面针对的是由于本机系统环境缺失而引起的.. 一般出

/usr/bin/ld: cannot find -lgcc_s 问题解决小记

博客分类: Linux/Ubuntu 由于之前用wubi装的ubuntu并且只给了它10G的硬盘空间,随着学习的深入这种 配备已经无法满足我的需求了.今天索性把ubuntu从windows上"卸载了",划了20G -_-的空余空间准备安装ubuntu双系统.双系统的安装过程很顺利,但接下来Qtopia的编译就不是很顺利了.我根据前面编译Qtopia时做的记 录文档对源文件还有系统变量进行了若干修改,但是实际编译的过程却跳出了我之前没有遇到的问题. Linux代码 收藏代码 /usr/b

[Android-Building]/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../liblzo2.so when searching for -llzo2

For /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../liblzo2.so when searching for -llzo2 USE: sudo apt-get install liblzo2-dev:i386 For /usr/bin/ld: skipping incompatible /usr/lib/../lib/libuuid.so when searching for -