Merc - Compiling with Cygwin and Linking for MCCP?

Posted by Altered on Fri 30 Jan 2009 06:48 AM — 5 posts, 26,051 views.

USA #0
Hello,

Since I know there are some sections regarding cygwin, I'm just curious if any coders who use cygwin ever added the mccp patch? I get a clean compile until link time, then I get 5 errors about deflateEnd, deflate_init ect. I made sure that I have -lz added to the link flags but for some reason, zlib doesn't seem to be linking. I've download and installed zlib fresh. Compiled it from scratch but nothing works.

Has anyone had this problem before? Any ideas to fix it?

Thanks,
Chris
Australia Forum Administrator #1
I have compiled SmaugFuss 1.7 with MCCP and it compiled and linked OK. When testing, it showed it was using compression.

However there was a recent report of a similar thing:

http://www.gammon.com.au/forum/bbshowpost.php?id=9118

I don't know what Cygwin have done, maybe look for a zlib development version or something. Or, try the zlib site itself, and simply download and compile:

http://www.zlib.net/
USA #2
Hello Nick,

Thanks for the reply. I figure out the linking issue. Aparently Cygwin ain't to brite.. If you add -lz at the top of a normal merc/rom make file, -lz doesn't work. But if -lz is called after everthing, it works and links fine.. Don't know why.

EG:
L_FLAGS = -lz

$(CC) $(L_FLAGS) -o merc.exe $(O_FILES)

The above won't link. But if you remove the -lz from lflags and link from here,

$(CC) $(L_FLAGS) -o merc.exe $(O_FILES) -lz <- At the end!

It links fine.

Never had that happen before but that worked. Again, thanks for the reply.

Chris
Australia Forum Administrator #3
You know, that sounds vaguely familiar. :)

I think I spent a while, ago, finding the same thing.

My guess is that the linker looks at libraries, in sequence, to see if anything mentioned previously needs that library.

So, for example:


gcc -o test.exe a.o -lmath b.o


Works if a.c needs the math library. However, not if b.c needs it, because the math references in b.c were not noticed at the time it processed -lmath.

Just a guess, but it seems to be supported by the evidence.

Actually, this is supported by the manual entry for gcc, as follows:

Quote:

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers to functions in z, those functions may not be loaded.



As for what you said:

Quote:

Aparently Cygwin ain't to brite..


Working as documented. ;)
Amended on Fri 30 Jan 2009 09:16 AM by Nick Gammon
USA #4
Hello Nick,

Thanks for the reply again. After the first compile with mccp, I thought all was well. MCCP showed as active in Roaclient. But then I checked out your MushClient and as soon as I turned on compression, it failed and a nice little error message showed up telling me that decompression failed. Anyway, I fixed the issue and then realized that the World Properties in MushClient show whether MCCP is active and also gives some nice details.

Your mud client has some excellent features for both players and mud coders. Very helpful in my case to see if mcp was working correctly.

Thanks a bunch,
Chris