Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

zlib & Visual C++ 6

504 views
Skip to first unread message

neilsolent

unread,
Mar 18, 2009, 5:47:37 PM3/18/09
to
Has anyone got the zlib source code (http://www.zlib.net/) working in
a Visual C++ 6 project?

Ideally I'd like to create the static library zlib.lib, and then add
it in to a project that needs to compress/uncompress some files. I'd
settle now for linking ot zlib1.dll at runtime.

However - I can't compile, because zlib.h inlcudes zconf.h which
includes unistd.h - which doesn't exist !

What am I doing wrong ?

thanks

Giovanni Dicanio

unread,
Mar 18, 2009, 6:33:10 PM3/18/09
to

"neilsolent" <n...@solenttechnology.co.uk> ha scritto nel messaggio
news:b59a6376-de1b-42d7...@w9g2000yqa.googlegroups.com...

Reading zconf.h, it seems to me that the only purpose to inlcude <unistd.h>
is to import some definitions like SEEK_* and off_t; however in the same
header file I see some preprocessor stuff to define those symbols in case
they are not defined yet:

#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset"
*/
#endif

I don't have VC6 installed on this machine, so I can't test that, but I
think that you can compile ZLIB on VC6 as well.
If you have problems with <unistd.h>, I would suggest to just uncomment its
#include line (VC6 header files like stdio.h etc. already defines SEEK_*
values).

HTH,
Giovanni

Geoff

unread,
Mar 18, 2009, 9:04:06 PM3/18/09
to

I have zlib 1.2.3 compiled without problems. It appears you have
either non-original sources or have run ./configure on them or defined
HAVE_UNISTD_H somehow.

The error is in line 289 of zconf.h and the relevant lines (287-302)
should read:

#if 0 /* HAVE_UNISTD_H -- this line is updated by
./configure */
# include <sys/types.h> /* for off_t */
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# define z_off_t off_t
#endif


#ifndef SEEK_SET
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus
"offset" */
#endif

#ifndef z_off_t
# define z_off_t long
#endif

In other words, line 287 should read #if 0, not #if 1.

neilsolent

unread,
Mar 19, 2009, 6:25:59 AM3/19/09
to
Giovanni, Geoff

I really appreciate your replies, many thanks.

I am happy to say this is now working (with 1 compiler warning)
thorugh this procedure:

Download and install zlib-1.2.3.exe from www.zlib.net

Edit zconf.h, change line 287 to:

old: #if 1 /* HAVE_UNISTD_H -- this line is updated by ./
configure */
new: #if 0 /* HAVE_UNISTD_H -- this line is updated by ./
configure */

(this is how the file is shipped - I didn't run configure - it's a
shell script, and no instructions on what flags to provide for Windows
anyway!)


Edit gzio.c, change line 884:

old: return gzseek(file, 0LL, SEEK_CUR);
new: return gzseek(file, 0L, SEEK_CUR);

(no idea why I have to do this !)

Then run this from the zlib-1.2.3 directory:

nmake -f win32/Makefile.msc

Add zlib.h, zconf.h, zlib.lib to VC++ project

Compiles, and works, but warning:

LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of
other libs; use /NODEFAULTLIB:library

Apart from this warning, all OK.

Giovanni Dicanio

unread,
Mar 19, 2009, 6:38:16 AM3/19/09
to

"neilsolent" <n...@solenttechnology.co.uk> ha scritto nel messaggio
news:79bb6a06-753b-4d8d...@z9g2000yqi.googlegroups.com...

> I am happy to say this is now working (with 1 compiler warning)
> thorugh this procedure:
>
> Download and install zlib-1.2.3.exe from www.zlib.net
>
> Edit zconf.h, change line 287 to:

> [...]

Neil: I think that the procedure is simpler and does not require manual
editing of source/header files.

I just used the VC6 IDE on a machine of mine and it worked fine without
editing any source/header files.
I did that:

Extract zlib source code archive; I downloaded it from:

http://www.zlib.net/zlib-1.2.3.tar.gz)

Then go to the subdirectory whose path is "projects\visualc6".

You will find the zlib.dsw file: open it with Visual C++ 6.

The select proper configuration from Project menu:

Project | Set Active Configuration

(e.g. choose "zlib - Win32 DLL Release")

Then select the build command from the Build menu (or press F7 short-cut).

It compiled fine with my version of Visual C++ 6 with Service Pack 6, with 0
errors and 0 warnings.

HTH,
Giovanni

neilsolent

unread,
Mar 19, 2009, 7:31:35 AM3/19/09
to
> It compiled fine with my version of Visual C++ 6 with Service Pack 6, with 0
> errors and 0 warnings.

Yes, same result here. I don't know why I had so many problems!

thanks.

azrafathima

unread,
Mar 3, 2010, 12:34:32 AM3/3/10
to
i'm trying to build zlib library, on windows using Visual C++ 6.0 service pack 5 from past 8 days,i'm able to build zlib1.dll under Win32_DLL_Release, Win32_DLL_Debug configurations without any errors, as given in readme of visual6 folder, however when i try to build it using Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code
* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code it gives error ml.exe not found, this error is coz Visualc i'm using is not a processor pack. i want to decompress a file run simple program like zpipe.c under zlib.net. for that do i need to build zlib1.dll using ASM code??
if i run zpipe.c it gives error saying zlib.h not found.
you have mentioned to edit zconf.h and gzio.c, i've edited that as well, you have mentioned about make as well where do i give that command in visual c++ 6.0
please can you guide me to build successfully zlib
Many thanks in advance.

neilsolent wrote:

Yes, same result here. I don't know why I had so many problems!thanks.

20-Mar-09

Yes, same result here. I do not know why I had so many problems!

thanks.

Previous Posts In This Thread:

On Wednesday, March 18, 2009 6:33 PM
Giovanni Dicanio wrote:

Re: zlib & Visual C++ 6


"neilsolent" <n...@solenttechnology.co.uk> ha scritto nel messaggio

news:b59a6376-de1b-42d7...@w9g2000yqa.googlegroups.com...

Reading zconf.h, it seems to me that the only purpose to inlcude <unistd.h>
is to import some definitions like SEEK_* and off_t; however in the same
header file I see some preprocessor stuff to define those symbols in case
they are not defined yet:

*/

I don't have VC6 installed on this machine, so I can't test that, but I
think that you can compile ZLIB on VC6 as well.
If you have problems with <unistd.h>, I would suggest to just uncomment its

values).

HTH,
Giovanni

On Wednesday, March 18, 2009 9:04 PM
Geoff wrote:

Re: zlib & Visual C++ 6


On Wed, 18 Mar 2009 14:47:37 -0700 (PDT), neilsolent
<n...@solenttechnology.co.uk> wrote:


I have zlib 1.2.3 compiled without problems. It appears you have
either non-original sources or have run ./configure on them or defined
HAVE_UNISTD_H somehow.

The error is in line 289 of zconf.h and the relevant lines (287-302)
should read:

./configure */
"offset" */

In other words, line 287 should read #if 0, not #if 1.

On Thursday, March 19, 2009 6:38 AM
Giovanni Dicanio wrote:

Re: zlib & Visual C++ 6


"neilsolent" <n...@solenttechnology.co.uk> ha scritto nel messaggio
news:79bb6a06-753b-4d8d...@z9g2000yqi.googlegroups.com...

Neil: I think that the procedure is simpler and does not require manual
editing of source/header files.

I just used the VC6 IDE on a machine of mine and it worked fine without
editing any source/header files.
I did that:

Extract zlib source code archive; I downloaded it from:

http://www.zlib.net/zlib-1.2.3.tar.gz)

Then go to the subdirectory whose path is "projects\visualc6".

You will find the zlib.dsw file: open it with Visual C++ 6.

The select proper configuration from Project menu:

Project | Set Active Configuration

(e.g. choose "zlib - Win32 DLL Release")

Then select the build command from the Build menu (or press F7 short-cut).

It compiled fine with my version of Visual C++ 6 with Service Pack 6, with 0
errors and 0 warnings.

HTH,
Giovanni

On Friday, March 20, 2009 10:44 PM
neilsolent wrote:

zlib & Visual C++ 6


Has anyone got the zlib source code (http://www.zlib.net/) working in
a Visual C++ 6 project?

Ideally I'd like to create the static library zlib.lib, and then add
it in to a project that needs to compress/uncompress some files. I'd
settle now for linking ot zlib1.dll at runtime.

However - I can't compile, because zlib.h inlcudes zconf.h which
includes unistd.h - which doesn't exist !

What am I doing wrong ?

thanks

On Friday, March 20, 2009 10:44 PM
neilsolent wrote:

Giovanni, GeoffI really appreciate your replies, many thanks.
Giovanni, Geoff

I really appreciate your replies, many thanks.

I am happy to say this is now working (with 1 compiler warning)
thorugh this procedure:

Download and install zlib-1.2.3.exe from www.zlib.net

Edit zconf.h, change line 287 to:

old: #if 1 /* HAVE_UNISTD_H -- this line is updated by ./


configure */
new: #if 0 /* HAVE_UNISTD_H -- this line is updated by ./
configure */

(this is how the file is shipped - I didn't run configure - it's a
shell script, and no instructions on what flags to provide for Windows
anyway!)


Edit gzio.c, change line 884:

old: return gzseek(file, 0LL, SEEK_CUR);
new: return gzseek(file, 0L, SEEK_CUR);

(no idea why I have to do this !)

Then run this from the zlib-1.2.3 directory:

nmake -f win32/Makefile.msc

Add zlib.h, zconf.h, zlib.lib to VC++ project

Compiles, and works, but warning:

LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of
other libs; use /NODEFAULTLIB:library

Apart from this warning, all OK.

On Friday, March 20, 2009 10:44 PM
neilsolent wrote:

Yes, same result here. I don't know why I had so many problems!thanks.

Yes, same result here. I do not know why I had so many problems!

thanks.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Dr. Dotnetsky's Cool .Net Tips and Tricks No. 26
http://www.eggheadcafe.com/tutorials/aspnet/8e390106-20d1-4b2b-be30-cde5d852348d/dr-dotnetskys-cool-net.aspx

Geoff

unread,
Mar 3, 2010, 2:40:56 AM3/3/10
to
Azra,

You need MASM 6.15 to build in asm mode. ml.exe is the executable for
MASM. I am not sure the MASM 8.0 binary will work with the VC++ 6.0
system but it is downloadable from Microsoft. The masm 8.0
installation package wants to see an installed Visual C++ 2005 Express
Edition.

There are other sources on the web for the older versions of MASM.

My version of the ZLIB source is 1.2.3, the .asm files use the
extended mmx Intel instructions and MASM 6.11 won't assemble them. I
replaced the masm 6.11 binary with the masm 6.15.8803 one and it works
well.

All the build modes will work if you have the tools installed
correctly. zpipe.c is an example file and not part of the zlib1.dll so
it should not be part of that project. But if your project can't find
the zlib.h file it means either zlib.h is not in the expected location
for the project or your project is not set up properly.

I recommend installing MASM32, then building the default zlib project
as it was defined by the nice zlib people, once you have successful
compiles and assembly working, then make your config changes.

Good hunting.

0 new messages