Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|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

To successfully build git from source without link errors I had to set the $LIBRARY_PATH variable, in addition to $CFLAGS and $LDFLAGS:

export LIBRARY_PATH="$HOME/lib"
share|improve this answer
    
Thank you. I had the exact same issue that I coud solve with this answer. – Patrick Schlüter Jun 3 '15 at 9:16

$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"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .