Zlib

Visual Studio 2022 solution that builds Zlib 1.2.12.

ICOULDN’T GET THE VISUAL STUDIO solutions in the Zlib 1.2.12 distro to work with VS 2022 so I made this one.

Visual Studio lets you choose the following options for your libraries — 32 possibilities in all.

  • debug or release;
  • 32 or 64 bit;
  • static or dll;
  • ZLIB_WINAPI defined or not defined;
  • linked to Visual Studio’s static or dll runtime.

Set the first two options on Visual Studio’s main window; the others on project properties.

This solution differs in three ways from the ones in the distro:

1. The distro’s static and dll binaries do not use the same calling convention for API functions. In this solution they both use the windows calling convention. Therefore, when you use any binary produced by this solution, you must #define ZLIB_WINAPI in your code before you include a zlib header file. If you want to change this behavior, remove ZLIB_WINAPI from “C/C++/Preprocessor/Preprocessor Definitions” on properties.

2. In the distro, the names of the dll library and its associated import library do not match. In this solution they are called zdll.dll and zdll.lib. If you want to rename them, you can do it automatically with "Build Events/Post-Build-Events" on properties.

3. I had to make six changes to the source code to eliminate compiler errors and warnings. That’s why I included source code in this solution. The changes are as follows:
FileLineWarning/ErrorHow fixed
crc32.c1089error 2708explicit cast added
crc32.c1106error2708explicit cast added
crc32.c1110error2373"ZEXPORT" added
deflate.c1915C4244 (conversion)warning disabled
deflate.c2040C4244 (conversion)warning disabled
deflate.c2150C4244 (conversion)warning disabled

Links

This page was first published on April 6, 2022 and last revised on April 19, 2022.

Comments