Search code examples
windowspostgresqlvisual-studiozlib

How to use zlibwapi instead of zlib for compiling PostgreSQL?


For PostgreSQL, I have compiled zlib 1.2.11 on msvc 2022. After compiling zlib I got following list of files.

 Directory of C:\Users\Documents\zlib_build\zlib-1.2.11\contrib\vstudio\vc14\x86\ZlibDllRelease

02/04/2022  11:33 AM    <DIR>          .
02/04/2022  11:33 AM    <DIR>          ..
02/04/2022  11:33 AM    <DIR>          Tmp
02/04/2022  11:33 AM           143,360 vc143.pdb
02/04/2022  11:33 AM           422,912 zlibwapi.dll
02/04/2022  11:33 AM            16,800 zlibwapi.exp
02/04/2022  11:33 AM            28,330 zlibwapi.lib
02/04/2022  11:33 AM           759,073 zlibwapi.map
02/04/2022  11:33 AM         6,696,960 zlibwapi.pdb
               6 File(s)      8,067,435 bytes
               3 Dir(s)  24,997,359,616 bytes free

But when I use the above Zlib library to compile PostgreSQL, I'm getting the following error.

  LINK : fatal error LNK1181: cannot open input file 'C:\library\zlib_build\ZlibDllRelease\lib\zdll.lib' 

This is the first time I compiled Zlib library, Is there any step I'm missing with which I would have gotten zdll.lib file. Or do I need to change anything related to Postgres compilation so that It would use zlibwapi.lib?


Solution

  • I couldn't find a way around zlibwapi, but found an easier way to build the zlib(1.2.11) library.

    1. Open "Developer Command Prompt" from Visual studio.
    2. Go to main zlib directory where source is uncompressed and run the following command to build it.

    nmake -f win32/Makefile.msc

    this command can be found in win32/Makefile.msc

    There we will get all the library files related to zlib in the current directory. Further, if required create a separate dir(zlib_build) and copy files to the respective directories as follows.

    zlib_build\lib -> zdll.*, zlib.*
    zlib_build\bin -> zlib1.*
    zlib_build\include -> zlib.h, zconf.h
    

    After using this in the path, I built PostgreSQL successfully.