Error: Building package zlib:x86-windows failed with: BUILD_FAILED
I'm trying to get started with vcpkg but haven't been able to install any packages.
I am on Windows 10:
> .\vcpkg env --triplet x64-windows
Microsoft Windows [Version 10.0.19042.928]
(c) Microsoft Corporation. All rights reserved.
And have Visual Studio Professional 2017 (this isn't something I can upgrade to a newer version) installed with the "Desktop development with C++" workload:

Yes - I am able to compile C++ projects in my VS installation.
Note: On a separate Windows 10 machine I have tested using vcpkg with Visual Studio Community Edition 2019 and had no problems.
I've managed to wander through countless Microsoft blog posts, StackOverflow answers, various personal dev blogs, and even dug through several issues posted here on GitHub. I've reinstalled/modified my Visual Studio install a bizarre number of times, not to mention the trusty old reboot "trick", but absolutely nothing has helped so I'm definitely feeling frustrated!
I can successfully clone the repo and run the bootstrap step as per the quick start guide for windows:
> git clone https://github.com/microsoft/vcpkg.git
...
> cd vcpkg
> .\bootstrap-vcpkg.bat -disableMetrics
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-02-24-d67989bce1043b98092ac45996a8230a059a2d7e/vcpkg.exe -> C:\Users\*****\git\vcpkg\vcpkg.exe
Done.
Unfortunately, this is the extent of the success I've had. Trying to install anything crashes:
vcpkg Crash Dump
> .\vcpkg install zlib
Computing installation plan...
A suitable version of cmake was not found (required v3.20.1). Downloading portable cmake v3.20.1...
Downloading cmake...
https://github.com/Kitware/CMake/releases/download/v3.20.1/cmake-3.20.1-windows-i386.zip -> C:\Users\*****\git\vcpkg\downloads\cmake-3.20.1-windows-i386.zip
Extracting cmake...
A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
Downloading 7zip...
https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> C:\Users\*****\git\vcpkg\downloads\7-zip.commandline.18.1.0.nupkg
Extracting 7zip...
A suitable version of nuget was not found (required v5.5.1). Downloading portable nuget v5.5.1...
Downloading nuget...
https://dist.nuget.org/win-x86-commandline/v5.5.1/nuget.exe -> C:\Users\*****\git\vcpkg\downloads\22ea847d-nuget.exe
The following packages will be built and installed:
zlib[core]:x86-windows -> 1.2.11#10
Detecting compiler hash for triplet x86-windows...
A suitable version of powershell-core was not found (required v7.1.3). Downloading portable powershell-core v7.1.3...
Downloading powershell-core...
https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x86.zip -> C:\Users\*****\git\vcpkg\downloads\PowerShell-7.1.3-win-x86.zip
Extracting powershell-core...
Could not locate cached archive: C:\Users\*****\AppData\Local\vcpkg\archives\8e\8e9fca6802fc361a672ac29aa230198d2c69e53b.zip
Starting package 1/1: zlib:x86-windows
Building package zlib[core]:x86-windows...
-- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz -> zlib1211.tar.gz...
-- Extracting source C:/Users/*****/git/vcpkg/downloads/zlib1211.tar.gz
-- Applying patch cmake_dont_build_more_than_needed.patch
-- Applying patch 0001-Prevent-invalid-inclusions-when-HAVE_-is-set-to-0.patch
-- Applying patch add_debug_postfix_on_mingw.patch
-- Applying patch 0002-android-build-mingw.patch
-- Using source at C:/Users/*****/git/vcpkg/buildtrees/zlib/src/1.2.11-e9a093319e.clean
-- Configuring x86-windows
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:105 (message):
Command failed: ninja -v
Working Directory: C:/Users/*****/git/vcpkg/buildtrees/zlib/x86-windows-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\Users\*****\git\vcpkg\buildtrees\zlib\config-x86-windows-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:324 (vcpkg_execute_required_process)
ports/zlib/portfile.cmake:23 (vcpkg_configure_cmake)
scripts/ports.cmake:142 (include)
Error: Building package zlib:x86-windows failed with: BUILD_FAILED
Please ensure you're using the latest portfiles with `.\vcpkg update`, then
submit an issue at https://github.com/Microsoft/vcpkg/issues including:
Package: zlib:x86-windows
Vcpkg version: 2021-01-13-d67989bce1043b98092ac45996a8230a059a2d7e
Additionally, attach any relevant sections from the log files above.
Just for laughs, I have attached the logs for both x64 and x86: config-x64-windows-out.log config-x86-windows-out.log x64-CMakeError.log x86-CMakeError.log
Any pointers, even to tell me that I've done something horribly backwards and dumb, would be greatly appreciated.
I am the same error
Detecting C compiler ABI info failed to compile with the following output: Change Dir: D:/software/vcpkg-master/buildtrees/brotli/x86-windows-rel/CMakeFiles/CMakeTmp
Run Build Command(s):D:/software/vcpkg-master/downloads/tools/ninja/1.10.1-windows/ninja.exe cmTC_e68ff && [1/2] Building C object CMakeFiles\cmTC_e68ff.dir\CMakeCCompilerABI.c.obj
[2/2] Linking C executable cmTC_e68ff.exe
FAILED: cmTC_e68ff.exe
cmd.exe /C "cd . && D:\software\vcpkg-master\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_e68ff.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~2\link.exe /nologo CMakeFiles\cmTC_e68ff.dir\CMakeCCompilerABI.c.obj /out:cmTC_e68ff.exe /implib:cmTC_e68ff.lib /pdb:cmTC_e68ff.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_e68ff.dir/manifest.res CMakeFiles\cmTC_e68ff.dir/manifest.rc" failed (exit code 0) with the following output: 系统找不到指定的文件。
ninja: build stopped: subcommand failed.
Determining if the C compiler works failed with the following output: Change Dir: D:/software/vcpkg-master/buildtrees/brotli/x86-windows-rel/CMakeFiles/CMakeTmp
Run Build Command(s):D:/software/vcpkg-master/downloads/tools/ninja/1.10.1-windows/ninja.exe cmTC_285f6 && [1/2] Building C object CMakeFiles\cmTC_285f6.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_285f6.exe
FAILED: cmTC_285f6.exe
cmd.exe /C "cd . && D:\software\vcpkg-master\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_285f6.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~1.0\VC\bin\AMD64_~2\link.exe /nologo CMakeFiles\cmTC_285f6.dir\testCCompiler.c.obj /out:cmTC_285f6.exe /implib:cmTC_285f6.lib /pdb:cmTC_285f6.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_285f6.dir/manifest.res CMakeFiles\cmTC_285f6.dir/manifest.rc" failed (exit code 0) with the following output: 系统找不到指定的文件。
ninja: build stopped: subcommand failed.
?
Hi @njalerikson
Thanks for posting this issue.
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Users/*****/git/vcpkg/downloads/tools/cmake-3.20.1-windows/cmake-3.20.1-windows-i386/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/*****/git/vcpkg/buildtrees/zlib/x64-windows-rel/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Users/*****/git/vcpkg/downloads/tools/ninja/1.10.1-windows/ninja.exe cmTC_74a31 && [1/2] Building C object CMakeFiles\cmTC_74a31.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_74a31.exe
FAILED: cmTC_74a31.exe
cmd.exe /C "cd . && C:\Users\*****\git\vcpkg\downloads\tools\cmake-3.20.1-windows\cmake-3.20.1-windows-i386\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_74a31.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_74a31.dir\testCCompiler.c.obj /out:cmTC_74a31.exe /implib:cmTC_74a31.lib /pdb:cmTC_74a31.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_74a31.dir/manifest.res CMakeFiles\cmTC_74a31.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
Please help check if you have installed one of Windows SDKs in Visual Studio 2017.
@xilutian Besides Windows SDK, please also make sure if you have installed English package in Visual Studio 2017.
@NancyLi1013 as per my above screenshot in the right-hand pane, I have the Windows 10 SDK (10.0.17763.0) selected and installed, is there some other SDK that needs to be installed?
@njalerikson
From your above screenshot, I didn't notice any Windows SDK that was installed. So please make sure you install Windows 10 SDK via Visual Studio Installer.
Edit: Sorry for my missing. You have installed it. Please ignore this comment.
Could you please try to reinstall Visual Studio or reinstall Windows SDK 10 and then rebuild this port? Please also help confirm if you install English package in Visual Studio?
njalerikson‘s screenshot show the Windows SDK is selected
I also have the same error using the msbuild-tools in docker:
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools `
--add Microsoft.VisualStudio.Component.VC.CMake.Project `
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
but I fixed it by adding the includeRecommended:
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.VCTools;includeRecommended`
@cosmoslx
Thanks for your comments. Sorry, I'm not sure what your problem is related with.