# \[3.28.0-rc | Regression?\] vcpkg error: building zlib:x64-windows failed with: BUILD\_FAILED

**URL:** https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230
**Category:** Usage
**Tags:** os:windows, gen:ninja
**Created:** [October 20, 2023, 3:24pm UTC](https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230 "2023-10-20T15:24:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Naheulf](https://discourse.cmake.org/user_avatar/discourse.cmake.org/naheulf/32/3929_2.png) [@Naheulf](https://discourse.cmake.org/u/Naheulf)
#### Post date: [October 20, 2023, 3:24pm UTC](https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230/1 "2023-10-20T15:24:48Z")

</div>

Got BUILD\_FAILED error message trying to install zlib with vcpkg and CMake 3.28.0-rc1 or CMake 3.28.0-rc2.

For more details see [[zlib] build failure with vcpkg · Issue #34597 · microsoft/vcpkg · GitHub](https://github.com/microsoft/vcpkg/issues/34597) (Resolved by using CMake 3.27.7)

I think there is a regression/incompatible change somewhere because it works with CMake 3.27.7.

---

<div class="post-metadata">

### Author: ![Neumann-A](https://discourse.cmake.org/user_avatar/discourse.cmake.org/neumann-a/32/1647_2.png) [@Neumann-A](https://discourse.cmake.org/u/Neumann-A)
#### Post date: [October 20, 2023, 4:02pm UTC](https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230/2 "2023-10-20T16:02:00Z")

</div>

The problem here ist that vcpkg CI updated to 3.28.0-rc2 is not able to reproduce the observed issue and I was also not able to reproduce the issue on my machine. So something is going on here since there are at least two persons reporting the issue.

---

<div class="post-metadata">

### Author: ![Tamis](https://discourse.cmake.org/user_avatar/discourse.cmake.org/tamis/32/3930_2.png) [@Tamis](https://discourse.cmake.org/u/Tamis)
#### Post date: [October 21, 2023, 5:12pm UTC](https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230/3 "2023-10-21T17:12:13Z")

</div>

Please see comment at github:

> <https://github.com/microsoft/vcpkg/issues/34597#issuecomment-1773865636>
>
> Hello I am trying to build zlib in my Windows 11 PC but it emits errors.
> If I t…ry another package like bzip2 it is working fine. But it fails all the time with the zlib.
> 
> \*\*Host Environment\*\*
> 
> Host: x64-windows 11
> Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33126.1 for x64
> vcpkg-tool version: git log -1
> commit 2815578f4a3486cec24c9b07d17e18e03bbaf667 (HEAD -\> master, origin/master, origin/HEAD)
> Visual Studio Community Edition 2022 (Preview), 2019, 2017 are installed with C++.
> Windows 10 SDK is also install, multiple versions (10.0.14, 15, 16, 17, 18 ...)
> RAM: 64GB
> 
> \*\*To Reproduce\*\*
> .\\vcpkg install zlib
> 
> \*\*Failure logs\*\*
> 
> .\\vcpkg install zlib --triplet=x64-windows-vs22
> \> Computing installation plan...
> \> The following packages will be built and installed:
> \> zlib:x64-windows-vs22 -\> 1.3
> \> Detecting compiler hash for triplet x64-windows-vs22...
> \> Restored 0 package(s) from C:\\Users\\PTamt\\AppData\\Local\\vcpkg\\archives in 74.5 us. Use --debug to see more details.
> \> Installing 1/1 zlib:x64-windows-vs22...
> \> Building zlib:x64-windows-vs22...
> \> -- Using cached madler-zlib-v1.3.tar.gz.
> \> -- Cleaning sources at C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/src/v1.3-8825ee792f.clean. Use --editable to skip cleaning for the packages you specify.
> \> -- Extracting source C:/Users/PTamt/source/repos/VCPKG/vcpkg/downloads/madler-zlib-v1.3.tar.gz
> \> -- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE\_-is-set-to-0.patch
> \> -- Applying patch 0002-skip-building-examples.patch
> \> -- Applying patch 0003-build-static-or-shared-not-both.patch
> \> -- Applying patch 0004-android-and-mingw-fixes.patch
> \> -- Using source at C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/src/v1.3-8825ee792f.clean
> \> -- Found external ninja('1.11.0').
> \> -- Configuring x64-windows-vs22
> \> -- Building x64-windows-vs22-dbg
> \> CMake Warning at scripts/cmake/vcpkg\_execute\_build\_process.cmake:65 (message):
> \> Please ensure your system has sufficient memory.
> \> Call Stack (most recent call first):
> \> installed/x64-windows/share/vcpkg-cmake/vcpkg\_cmake\_build.cmake:74 (vcpkg\_execute\_build\_process)
> \> installed/x64-windows/share/vcpkg-cmake/vcpkg\_cmake\_install.cmake:16 (vcpkg\_cmake\_build)
> \> ports/zlib/portfile.cmake:26 (vcpkg\_cmake\_install)
> \> scripts/ports.cmake:168 (include)\`
> \> 
> \> 
> \> -- Restarting build without parallelism
> \> CMake Error at scripts/cmake/vcpkg\_execute\_build\_process.cmake:134 (message):
> \> Command failed: "C:/Program Files/CMake/bin/cmake.exe" --build . --config Debug --target install -- -v -j33
> \> Working Directory: C:/Users/PTamt/source/repos/VCPKG/vcpkg/buildtrees/zlib/x64-windows-vs22-dbg
> \> See logs for more information:
> \> C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\install-x64-windows-vs22-dbg-out.log
> \> C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\install-x64-windows-vs22-dbg-out-1.log
> \> 
> \> Call Stack (most recent call first):
> \> installed/x64-windows/share/vcpkg-cmake/vcpkg\_cmake\_build.cmake:74 (vcpkg\_execute\_build\_process)
> \> installed/x64-windows/share/vcpkg-cmake/vcpkg\_cmake\_install.cmake:16 (vcpkg\_cmake\_build)
> \> ports/zlib/portfile.cmake:26 (vcpkg\_cmake\_install)
> \> scripts/ports.cmake:168 (include)
> \> 
> \> 
> \> error: building zlib:x64-windows-vs22 failed with: BUILD\_FAILED
> \> Elapsed time to handle zlib:x64-windows-vs22: 6.9 s
> \> Please ensure you're using the latest port files with \`git pull\` and \`vcpkg update\`.
> \> Then check for known issues at:
> \> https://github.com/microsoft/vcpkg/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+zlib
> \> You can submit a new issue at:
> \> https://github.com/microsoft/vcpkg/issues/new?title=\[zlib\]+Build+error&body=Copy+issue+body+from+C%3A%2FUsers%2FPTamt%2Fsource%2Frepos%2FVCPKG%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue\_body.md
> 
> 
> I also attach the diagnostic logs
> C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\install-x64-windows-vs22-dbg-out.log
> C:\\Users\\PTamt\\source\\repos\\VCPKG\\
> 
> \[install-x64-windows-vs22-dbg-out-1.log\](https://github.com/microsoft/vcpkg/files/13041932/install-x64-windows-vs22-dbg-out-1.log)
> 
> \[install-x64-windows-vs22-dbg-out.log\](https://github.com/microsoft/vcpkg/files/13041927/install-x64-windows-vs22-dbg-out.log)
> 
> I tried to run execute the commands stated in the logs by hand:
> 
> \` C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\x64-windows-vs22-dbg\> C:/PROGRA~1/CMake/bin/cmcldeps.exe RC C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\src\\v1.3-8825ee792f.clean\\win32\\zlib1.rc CMakeFiles\\zlib.dir\\win32\\zlib1.rc.res.d CMakeFiles\\zlib.dir\\win32\\zlib1.rc.res "Note: including file: " "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33126/bin/Hostx64/x64/cl.exe" "C:\\PROGRA~2\\Windows Kits\\10\\bin\\10.0.22621.0\\x64\\rc.exe" -DNO\_FSEEKO -DZLIB\_DLL -D\_CRT\_NONSTDC\_NO\_DEPRECATE -D\_CRT\_SECURE\_NO\_DEPRECATE -I C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\src\\v1.3-8825ee792f.clean -I C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\x64-windows-vs22-dbg -c65001 /DWIN32 -D\_DEBUG /fo CMakeFiles\\zlib.dir\\win32\\zlib1.rc.res C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\src\\v1.3-8825ee792f.clean\\win32\\zlib1.rc\`
> output
> 
> \`cl : Command line warning D9002 : ignoring unknown option '-c65001'
> C:\\Users\\PTamt\\source\\repos\\VCPKG\\vcpkg\\buildtrees\\zlib\\src\\v1.3-8825ee792f.clean\\win32\\zlib1.rc(1): fatal error C1083: Cannot open include file: 'winver.h': No such file or directory\`
> 
> So it seems that \`winver.h\` seems not to be found. But the file exists in my machine under path:
> \`C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.22621.0\\um\`
> 
> What it might goes wrong?
> Does vcpkg needs any includes in order to work and find that file?
> 
> I am at your disposal for any additional logs

I was able to bisect the commit chain and reproduce the issue.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [October 23, 2023, 4:11pm UTC](https://discourse.cmake.org/t/3-28-0-rc-regression-vcpkg-error-building-zlib-x64-windows-failed-with-build-failed/9230/4 "2023-10-23T16:11:53Z")

</div>

For reference, this is now tracked as [CMake Issue 25355](https://gitlab.kitware.com/cmake/cmake/-/issues/25355).
