Linking with zlib

Igor Pechtchanski pechtcha@cs.nyu.edu
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 <http://mergelog.sourceforge.net/>
> (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.

Mark,

This is definitely a bug in zmergelog's Makefile:

gcc -DHAVE_LIBZ=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_MKTIME=1 -I.
    -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

gcc -DHAVE_LIBZ=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_MKTIME=1 -I.
    -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
sequence.

Hope this helps,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,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:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list