User Tools

Site Tools


c:build:build-zlib-statically-on-windows-vs2017

This is an old revision of the document!


Build zlib statically on Windows using Visual Studio 2017

1. Download zlib from zlib site - latest version now is 1.2.11

2. Unzip archive in a folder (C:\zlib)

2. Open 'Developer Command Prompt for VS 2017'. Click on Windows start button and start typing Developer Command … Click on the cmd (evetually right click on it and choose 'Run as administrator'

3. cd C:\zlib

4. 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

5. 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

6. Use zlib.lib and zlib.h in your project.

c/build/build-zlib-statically-on-windows-vs2017.1565716852.txt.gz · Last modified: 2019/08/13 20:20 by odefta