====== Build zlib statically on Windows using Visual Studio 2017 ====== - Download zlib from [[http://zlib.net/zlib-1.2.11.tar.gz|zlib site - latest version now is 1.2.11]] - Unzip archive in a folder (C:\zlib) - Open 'Developer Command Prompt for VS 2017'. Click on Windows start button and start typing 'Developer Command...', then click on the cmd (evetually right click on it and choose 'Run as administrator') - cd C:\zlib - **nmake /f win32/Makefile.msc** Output: Microsoft (R) Program Maintenance Utility Version 14.16.27032.1 Copyright (C) Microsoft Corporation. All rights reserved. cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\adler32.c adler32.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\compress.c compress.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\crc32.c crc32.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\deflate.c deflate.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\gzclose.c gzclose.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\gzlib.c gzlib.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\gzread.c gzread.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\gzwrite.c gzwrite.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\infback.c infback.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\inflate.c inflate.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\inftrees.c inftrees.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\inffast.c inffast.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\trees.c trees.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\uncompr.c uncompr.c cl -c -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" .\zutil.c zutil.c lib -nologo -out:zlib.lib adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj rc /dWIN32 /r /fozlib1.res ./win32/zlib1.rc Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved. link -nologo -debug -incremental:no -opt:ref -def:./win32/zlib.def -dll -implib:zdll.lib -out:zlib1.dll -base:0x5A4C0000 adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj zlib1.res Creating library zdll.lib and object zdll.exp if exist zlib1.dll.manifest mt -nologo -manifest zlib1.dll.manifest -outputresource:zlib1.dll;2 cl -c -I. -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" ./test\example.c example.c link -nologo -debug -incremental:no -opt:ref example.obj zlib.lib if exist example.exe.manifest mt -nologo -manifest example.exe.manifest -outputresource:example.exe;1 cl -c -I. -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" ./test\minigzip.c minigzip.c link -nologo -debug -incremental:no -opt:ref minigzip.obj zlib.lib if exist minigzip.exe.manifest mt -nologo -manifest minigzip.exe.manifest -outputresource:minigzip.exe;1 link -nologo -debug -incremental:no -opt:ref -out:example_d.exe example.obj zdll.lib if exist example_d.exe.manifest mt -nologo -manifest example_d.exe.manifest -outputresource:example_d.exe;1 link -nologo -debug -incremental:no -opt:ref -out:minigzip_d.exe minigzip.obj zdll.lib if exist minigzip_d.exe.manifest mt -nologo -manifest minigzip_d.exe.manifest -outputresource:minigzip_d.exe;1 ===== Output files ===== The output files are: * **zlib.lib and zlib.pdb - static library lib and pdb** * zdll.lib, zlib1.dll and zlib1.pdb - for dynamic linking - lib, dll and pdb **Use zlib.lib and zlib.h in your project.**