I'm trying to install git from source as a non-root user. After typing "make" the following error occurs:

Link git-daemon
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status

I already installed libz from source and set the environment variable LD_LIBRARY_PATH to "$HOME/lib". This dir contains libz.a, libz.so, libz.so.1 and libz.so.1.2.5.

What am I doing wrong?

link|improve this question
I'm unable to find the -lz option on either a GNU based Linux box or a BSD based OS X system. It sounds like there may be a bug in the package you're trying to install. What platform are you attempting to install git-daemon on? – d34dh0r53 Dec 23 '11 at 17:55
@d34dh0r53: The option is -l, with an argument "z"; meaning "link against libz", it exists on all linkers in some form or other. – grawity Dec 23 '11 at 19:16
feedback

1 Answer

$LD_LIBRARY_PATH is for the dynamic loader ld-linux.so, and is only used when executing already compiled and linked binaries.

When linking, you need to specify the library path using -L, as in -L$HOME/lib. With projects using autoconf (./configure), you can specify the flag in $LDFLAGS:

export dir="$HOME"
export CFLAGS="-I$dir/include"
export LDFLAGS="-L$dir/lib"
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.