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

摘要:
Whatdoescannotfind-lzmean?Here'sthefullerrormessage:external/qemu/Makefile.android:1101:warning:overridingcommandsfortarget`external/qemu/android/avd/hw-config-defs.h'external/qemu/Makefile.android:933:warning:ignoringoldcommandsfortarget`external/qemu/android/avd/hw-config-defs.h'hostSharedLib:libneo_cgi(out/host/linux-x86/obj/lib/libneo_cgi.so)/usr/bin/ld:skippingincompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.sowhensearchingfor-lz/usr/bin/ld:skippingincompatible/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../libz.awhensearchingfor-lz/usr/bin/ld:skippingincompatible/usr/lib/libz.sowhensearchingfor-lz/usr/bin/ld:skippingincompatible/usr/lib/libz.awhensearchingfor-lz/usr/bin/ld:cannotfind-lzcollect2:ldreturned1exitstatusmake:***[out/host/linux-x86/obj/lib/libneo_cgi.so]Error1AndmyGCCversionoutput:scheung@scheung-virtual-box:/media/EXTDIV/mydroid$gcc--versiongcc(Ubuntu4.4.3-4ubuntu5)4.4.3Copyright(C)2009FreeSoftwareFoundation,Inc.Thisisfreesoftware;seethesourceforcopyingconditions.ThereisNOwarranty;notevenforMERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Ialreadyhavethezlib1g-devlibraryinstalled:$sudoapt-getinstallzlib1g-devReadingpackagelists...DoneBuildingdependencytreeReadingstateinformation...Donezlib1g-devisalreadythenewestversion.(Igetthatfromthislink.)linuxgcclinkershareimprovethisquestioneditedOct22'12at22:31Kazark2,81532152askedJul30'10at17:34michael15.4k471462277Wow,really?Eventhoughhespecificallysayslessthan4inchesaboveyourcommentthathedoeshaveitinstalled?

原文网址: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:

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.
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 ;)

免责声明:文章转载自《【转】“/usr/bin/ld: cannot find -lz”》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇命令行工具cmderCentOS6.5 mysql 5.5安装下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

Datax3.0使用说明

任务是DataX作业的最小单位。每个任务负责一些数据的同步。DataX的调度决策思想是:-DataXJob根据数据库和表划分为100个任务。...

UOS怎么访问windows共享的文件夹

至此就共享成功了如何查看一个文件夹的绝对路径双击打开UOS桌面中的winshare文件夹,右键点击在终端中打开然后再输入pwd,记住这个路径,这个就是UOS中这个目录的绝对路径了...

可用的rtmp互联网地址

Rtmp:vlc使用ffmpeg获取Rtmp网络流。代码文件路径:vlc-2.2.1 modulesassesavio。hvlc-2.2.1模块。c在模块的开放回调函数OpenAvio中,使用以下代码打开rtmp网络流。avio_打开(&avio_FLAG_READ);//或者这个avio_open2(&sys-&gt...

vscode 用户设置与工作区设置

用户设置与工作空间设置VSCode提供了两种设置方式:-用户设置:这种方式进行的设置,会应用于该用户打开的所有工程;-工作空间设置:工作空间是指使用VSCode打开的某个文件夹,在该文件夹下会创建一个名为.vscode的隐藏文件夹,里面包含着仅适用于当前目录的VSCode的设置,工作空间的设置会覆盖用户的设置。更改默认用户设置与工作空间设置VSCode的设置...

Fiddler抓包7-post请求(json)(转载)

2.查看上图中的红色框:这里只支持application/x-www-form-urlencoded格式的body参数,即json格式。您需要检查JOSN列中的five和xml。1.如果遇到text/xml格式的正文,如下图所示...

jquery跨域请求数据

Jquery跨域请求数据Jquery跨请求数据。事实上,这很容易。请遵循以下步骤:首先,编写js,通过get获取远程数据。请注意,回调参数应添加在链接之后,这意味着将回调函数地址传输到远程页面。',{params},函数cb{alert;alert;},'json');第二:编写处理程序。publicvoidProcessRequest{context.Re...