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.
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:
File | Line | Warning/Error | How fixed |
crc32.c | 1089 | error 2708 | explicit cast added |
crc32.c | 1106 | error2708 | explicit cast added |
crc32.c | 1110 | error2373 | "ZEXPORT" added |
deflate.c | 1915 | C4244 (conversion) | warning disabled |
deflate.c | 2040 | C4244 (conversion) | warning disabled |
deflate.c | 2150 | C4244 (conversion) | warning disabled |
This is the 2012 version incorporated by reference in EPUB OCF 3.1, not the current version.
By Raymond Chen. From the Old New Thing.
By Yaakov Smith.
This page was first published on April 6, 2022 and last revised on April 19, 2022.