Linking with zlib

Igor Pechtchanski
Wed Sep 24 23:43:00 GMT 2003

On Thu, 25 Sep 2003, Mark Himsley wrote:

> I'm sorry if I sound ignorant but I've been looking at this problem for a
> few days and I'm lost. I have googled but failed to find a relevant answer.
> I have been trying to compile mergelog <>
> (or more importantly zmergelog which is built from the same source file)
> under Cygwin.
> Zmergelog is a fairly simple program to merge gziped Apache log files. It
> uses zlib to open and read the gziped files.
> Mergelog's configure script appears to find that I have zlib installed but
> when I get to make zmergelog the link fails with undefined references to
> _gzopen _gzread and _gzclose.
> I would be really grateful if someone could give me a hint how to compile
> zmergelog under Cygwin.
> The output of the configure / make session and also cygcheck are attached.
> Many thanks in advance.


This is definitely a bug in zmergelog's Makefile:

    -I.  -g -O2 -lz -DVERSION=\"4.5\" -Wall -DUSE_ZLIB mergelog.c -o zmergelog
The -lz should go to the *end* of the compile line (at least, after the .c
file).  In other words, the correct gcc invocation is

    -I.  -g -O2 -DVERSION=\"4.5\" -Wall -DUSE_ZLIB mergelog.c -lz -o zmergelog

I haven't seen the Makefile, but I have a feeling that this is because the
"zmergelog" target depends on a ".c" file instead of a ".o".  If you
changed the dependence to "mergelog.o", you might get the correct link

Hope this helps,
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list