原文网址: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”的更多相关文章

  1. 编译错误:/usr/bin/ld: cannot find -lz

    编译时出现错误/usr/bin/ld: cannot find -lz,安装zlib和zlib-devel yum install zlib yum install zlib-devel

  2. /usr/bin/ld: cannot find -lz

    同事在一台机器上新安装的CentOS,我拷贝一个项目在上面编译,老是报如下错误: “/usr/bin/ld: cannot find -lz” 说明:libz.so是有的,在/lib64下面 我设置环 ...

  3. android编译错误--/usr/bin/ld: cannot find -lz

    编译时出现/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../libz.so when se ...

  4. 编译的时候出现"/usr/bin/ld: cannot find -lz

    编译的时候出现"/usr/bin/ld: cannot find -lz"错误,需要安装zlib-dev这个包,在线安装命令为:apt-get install zlib1g-dev ...

  5. /usr/bin/ld.bfd.real: cannot find -lGL /usr/bin/ld.bfd.real: cannot find -lX11

    /usr/bin/ld.bfd.real: cannot find -lGL /usr/bin/ld.bfd.real: cannot find -lX11 根据网上大多数的说法,以及官网的介绍.截至 ...

  6. linux /usr/bin/ld cannot find 解决

    问题: 在linux环境编译应用程式或lib的source code时常常会出现如下的错误讯息: /usr/bin/ld: cannot find -lxxx 这些讯息会随着编译不同类型的source ...

  7. linux /usr/bin/ld: cannot find -lxxx

    在linux环境编译应用程式或lib的source code时出现如下错误:/usr/bin/ld: cannot find -lxxx 这些讯息会随着编译不同类型的source code 而有不同的 ...

  8. 关于usr/bin/ld: cannot find -lxxx问题总结

    /usr/bin/ld: cannot find -lxxx问题总结   linux下编译应用程序常常会出现如下错误:     /usr/bin/ld: cannot find -lxxx       ...

  9. CentOS6.5安装readline时报错:/usr/bin/ld : cannot find -lncurses

    CentOS6.5安装readline时报错:/usr/bin/ld : cannot find -lncurses 解决方法: 安装ncurses-devel,输入命令: #yum install ...

随机推荐

  1. java三线程循环有序打印ABC

    迅雷笔试题: 编写一个程序,开启3个线程,这3个线程的ID分别为A.B.C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示:如:ABCABC….依次递推. 解决思路:每个线 ...

  2. hdu 4778 Gems Fight! 博弈+状态dp+搜索

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4102743.html 题目链接:hdu 4778 Gems Fight! 博弈+状态dp+搜 ...

  3. OpenCV2学习笔记04:图像的读取与显示

    1. 图像读取:imread() Mat imread( ) 参数介绍: filename: 待加载的文件名称. flags: 此标志用来指定被加载图像的颜色类型(color type).这个标志的取 ...

  4. ajax返回json处理

    在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式: 1.一种为使用eval()函数. 2. 使用Function对象来进行返回解析. (一)以jquery异步获取的数据类型--json ...

  5. Jquery ajax使用json形式通信

    前台JS $.ajax({                              type: 'post',                              url: 'HandlerL ...

  6. WPF MVVM 中怎样在ViewModel总打开的对话框在窗体之前

    今天在WPF的项目中,写打印插件,在ViewModel中对需要弹出打印对话框,而对话框如果没有Owner所属的时候经常会被当前应用程序遮住,导致我都不知道到底弹出来没有! 参照:http://www. ...

  7. JAVA学习资料整理

    今天偶然间发现之前一个群里发过的一篇关于JAVA学习资料的东西.本着服务大众的精神,搬来了博客园: <JAVA编程思想>第四版(英文原版) 下载地址:http://115.com/file ...

  8. java 中的 & | ~ ^ 运算符分析

    1.与运算符与运算符用符号“&”表示,其使用规律如下:两个操作数中位都为1,结果才为1,否则结果为0,例如下面的程序段.public class data13{public static vo ...

  9. Python设计模式——建造者模式

    需求,画人物,要求画一个人的头,左手,右手,左脚,右脚和身体,画一个瘦子,一个胖子 不使用设计模式 #encoding=utf-8 __author__ = 'kevinlu1010@qq.com' ...

  10. EL四大作用域 9个jsp对象有效范围 及 对应的类

    java中request,session,application的作用范围 page,request,session,application四者的作用范围: page的作用范围是当前页面:对应El表达 ...