CMake zlib build on Windows

elveatles picture elveatles · Apr 8, 2015 · Viewed 20.6k times · Source

I'm trying to build zlib 1.2.8 for Windows using CMake, but I get build errors that I don't know how to fix. Here's my CMake GUI:

enter image description here

This generates without errors, but when I build the resulting solution. I get this error:

2>------ Build started: Project: zlib, Configuration: Release x64 ------
2> Creating library C:/Users/erik/Documents/zlib/1.2.8/project/zlib-1.2.8-vc10/Release/zlib.lib and object C:/Users/erik/Documents/zlib/1.2.8/project/zlib-1.2.8-vc10/Release/zlib.exp
2> inflate.obj : error LNK2019: unresolved external symbol inflate_fast referenced in function inflate
2>infback.obj : error LNK2001: unresolved external symbol inflate_fast
2>C:\Users\erik\Documents\zlib\1.2.8\project\zlib-1.2.8-vc10\Release\zlib.dll : fatal error LNK1120: 1 unresolved externals

I don't know how I can fix this, so I appreciate any help.

Answer

bames53 picture bames53 · Apr 8, 2015

According to https://wiki.apache.org/httpd/Win64Compilation a very similar error means:

This means you have a typo in either -DASMV -DASMINF or your OBJ="inffasx64.obj gvmat64.obj inffas8664.obj" since inflate_fast is defined in inffas8664.c.


I was able to successfully build with a simple:

mkdir C:\Builds\zlib; cd C:\Builds\zlib
cmake -G "Visual Studio 12 2013" -A x64 D:\Downloads\zlib-1.2.8\
cmake --build .

I looked at my cmake cache and I see that AMD64 is set to false, unlike what your cmake-gui window shows. Setting it to true it results all kinds of build errors for me, though not the ones you show.

CMakeLists.txt says this option is to enable an AMD64 assembly implementation. Just doing without this seems to be the easiest solution.