Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

$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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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