tags:

views:

228

answers:

2

I am trying to compile android source code under ubuntu 10.04.

I get the following error saying "/usr/bin/ld: cannot find -lz". Can you please tell me how can I fix it? what does "can't find -lz" mean?

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
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 has '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: http://www.eqjunkies.com/2008/07/howto-usrbinld-cannot-find-lz/

A: 

It means you asked it to include the library 'libz.a' or 'libz.so' containing a compression package, and although the compiler found some files, none of them was suitable for the build you are using.

You either need to change your build parameters or you need to get the correct library installed or you need to specify where the correct library is on the link command line with a -L/where/it/is/lib type option.

Jonathan Leffler
+2  A: 

You are cross-compiling, but your linker only finds the libz library for the host.

It seems that there is something wrong with your Makefile. Is it generated by ./configure (or something similar)?

If so, have a look if the output says something about libz.

The zlib1g-dev from Ubuntu is for the Host (Ubuntu) and not for the target (Android). Compiling works fine, because you compiler finds the host header files of libz.

Note that this should not happen: When cross-compiling you shoud never use header-files or libraries from the host.

IanH
From here, http://source.android.com/source/download.html, i just need to download the source 'repo sync' and then do a 'make'. That is. So I am not sure why here i something wrong for my Makefile.in.
michael
In my opinion, it should not happen that a Makefile cross-compiles in a way that the compiler can find the host-include-files and the linker can find the host-libraries, because this can introduce very weird errors. Imagine what happens if - for some reason - an include file is missing, but the one of the host system is used. If there is a difference that results in a ABI change (e.g. added or missing member variable), the resulting binary crashes on the target.
IanH