原文网址: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. WIX Custom Action (immediate, deffered, rollback)

    Following content is directly reprinted from From MSI to WiX, Part 19 - The Art of Custom Action, Pa ...

  2. Skia

    1 What is SKIA. Skia is an open source 2D graphics library which provides common APIs that work acro ...

  3. linux RedHat6.4下nginx安装

    安装rpm 检测是否有已安装rpm包: rpm–qa | grep pcre rpm–qa | grep zlib rpm–qa | grep openssl 若没有则需安装(这些包可以在redhat ...

  4. SQL索引问题

    很多文章都提到使用IN,OR会破坏索引,造成全表扫描,但实际测试却不是这样. ) 或者 ,) 以上SQL文,第一组(=,IN),第二组(=,OR,IN),每一组的两个SQL文都使用相同的执行计划,执行 ...

  5. 转 修改oracle用户密码永不过期

      1.查看用户的proifle是哪个,一般是default: sql>SELECT username,PROFILE FROM dba_users; 2.查看指定概要文件(如default)的 ...

  6. 关于aspx模板页面元素路径的问题,以及对模板页面的理解

    模板页面仅是模板,它不是单独存在的页面,它的路径就是引用它的内容页面的路径. 换句话说,模板页面,只是内容页面上固定的部分.     模板页面引用了的js和CSS,内容页面就不用重新引用了   css ...

  7. oracle学习总结

    set linesize 120 set pagesize 20 column file_name format a8 v$nls_parameters 数据字典中的一个表 关于null的注意: 1: ...

  8. windows store app Lifecycle

    1.Activated 2.Suspended 3.Resumed 4.Terminated 对应的 js代码: (function () { "use strict"; WinJ ...

  9. 关于\t

    tail -n 10000 sample_dbl.txt | python sitemap.py | sort -k 1 -t $'\t' | python sitecombiner.py > ...

  10. failed with: java.lang.NullPointerException

    failed with: java.lang.NullPointerException 需要在nutch的配置文件 'conf/nutch-site.xml'. 里设置如下,不然就报上面的错误了. 当 ...