win11 使用 vcpkg 安装库,BUILD_FAILED 失败

win11 vcpkg 安装失败

在 windows11 上面使用 vcpkg 安装 librdkafka,多次安装都报错:

PS C:\Users\Lenovo\temp\vcpkg> ./vcpkg install librdkafka:x64-windows
Computing installation plan...
The following packages will be built and installed:
    librdkafka:x64-windows@2.6.0
  * lz4:x64-windows@1.10.0
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
Compiler found: D:/ProgramFiles/MicrosoftVisualStudio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\Lenovo\AppData\Local\vcpkg\archives in 256 us. Use --debug to see more details.
Installing 1/2 lz4:x64-windows@1.10.0...
Building lz4:x64-windows@1.10.0...
-- Using cached lz4-lz4-v1.10.0.tar.gz
-- Cleaning sources at C:/Users/Lenovo/temp/vcpkg/buildtrees/lz4/src/v1.10.0-61bd08d80e.clean. Use --editable to skip cleaning for the packages you specify.
-- Extracting source C:/Users/Lenovo/temp/vcpkg/downloads/lz4-lz4-v1.10.0.tar.gz
-- Applying patch target-lz4-lz4.diff
-- Using source at C:/Users/Lenovo/temp/vcpkg/buildtrees/lz4/src/v1.10.0-61bd08d80e.clean
-- Found external ninja('1.12.1').
-- Configuring x64-windows
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:127 (message):
    Command failed: D:/ProgramFiles/MicrosoftVisualStudio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe -v
    Working Directory: C:/Users/Lenovo/temp/vcpkg/buildtrees/lz4/x64-windows-rel/vcpkg-parallel-configure
    Error code: 1
    See logs for more information:
      C:\Users\Lenovo\temp\vcpkg\buildtrees\lz4\config-x64-windows-dbg-CMakeCache.txt.log
      C:\Users\Lenovo\temp\vcpkg\buildtrees\lz4\config-x64-windows-rel-CMakeCache.txt.log
      C:\Users\Lenovo\temp\vcpkg\buildtrees\lz4\config-x64-windows-dbg-CMakeConfigureLog.yaml.log
      C:\Users\Lenovo\temp\vcpkg\buildtrees\lz4\config-x64-windows-rel-CMakeConfigureLog.yaml.log
      C:\Users\Lenovo\temp\vcpkg\buildtrees\lz4\config-x64-windows-out.log

Call Stack (most recent call first):
  installed/x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake:269 (vcpkg_execute_required_process)
  ports/lz4/portfile.cmake:16 (vcpkg_cmake_configure)
  scripts/ports.cmake:203 (include)


error: building lz4:x64-windows failed with: BUILD_FAILED
See https://learn.microsoft.com/vcpkg/troubleshoot/build-failures?WT.mc_id=vcpkg_inproduct_cli for more information.
Elapsed time to handle lz4:x64-windows: 2 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+lz4
You can submit a new issue at:
  https://github.com/microsoft/vcpkg/issues/new?title=[lz4]+Build+error+on+x64-windows&body=Copy%20issue%20body%20from%20C%3A%2FUsers%2FLenovo%2Ftemp%2Fvcpkg%2Finstalled%2Fvcpkg%2Fissue_body.md

PS C:\Users\Lenovo\temp\vcpkg>

按照报错,看了错误log:

---
events:
-
kind: "message-v1"
backtrace:
- "C:/Users/Lenovo/temp/vcpkg/downloads/tools/cmake-3.30.1-windows/cmake-3.30.1-windows-i386/share/cmake-3.30/Modules/CMakeDetermineSystem.cmake:205 (message)"
- "CMakeLists.txt:31 (project)"
message: |
The system is: Windows - 10.0.26100 - AMD64
-
kind: "message-v1"
backtrace:
- "C:/Users/Lenovo/temp/vcpkg/downloads/tools/cmake-3.30.1-windows/cmake-3.30.1-windows-i386/share/cmake-3.30/Modules/CMakeDetermineCompilerId.cmake:17 (message)"
- "C:/Users/Lenovo/temp/vcpkg/downloads/tools/cmake-3.30.1-windows/cmake-3.30.1-windows-i386/share/cmake-3.30/Modules/CMakeDetermineCompilerId.cmake:64 (__determine_compiler_id_test)"
- "C:/Users/Lenovo/temp/vcpkg/downloads/tools/cmake-3.30.1-windows/cmake-3.30.1-windows-i386/share/cmake-3.30/Modules/CMakeDetermineCCompiler.cmake:123 (CMAKE_DETERMINE_COMPILER_ID)"
- "CMakeLists.txt:31 (project)"
message: |
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: D:/ProgramFiles/MicrosoftVisualStudio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
Build flags: /nologo;/DWIN32;/D_WINDOWS;/utf-8;/MP
Id flags:

The output was:
2
CMakeCCompilerId.c
LINK : fatal error LNK1104: cannot open file 'kernel32.lib'

报错主要原因应该是这个 cannot open file 'kernel32.lib' ,用 Everything 全局搜索了下,发现电脑里面没有这东西。

本机是 win11,虽然是新电脑,但是也已经用 Visual Studio Installer 安装了 Visual Studio Community 2022,安装了“使用c++的桌面开发”套件,按说是包含了一整套的安装、调试、生成工具以及包、按说不会缺少什么啊。

又查了查它应该有的路径,应该是在:

C:\Program Files (x86)\Windows Kits\10\Lib\<version>\um\x64\kernel32.lib

这里。

仔细一看,这应该是 win10 SDK 的路径啊

重新打开 Visual Studio Installer,补充安装 Windows 10 SDK
在这里插入图片描述
安装完成,重启,重新安装,安装成功!
在这里插入图片描述

综上所述:vcpkg 安装过程中可能需要 win 10 SDK 的一些库的参与,即使是 win11 机器,用 Visual Studio Installer 安装库依赖的时候,也值得都安装一下

E:\vcpkg\vcpkg-master>.\vcpkg remove hiredis The following packages are not installed: hiredis:x64-windows E:\vcpkg\vcpkg-master>.\vcpkg install hiredis --clean-after-build Computing installation plan... The following packages will be built and installed: hiredis:x64-windows@1.2.0 Detecting compiler hash for triplet x64-windows... -- Automatically setting %HTTP(S)_PROXY% environment variables to "127.0.0.1:7890". Compiler found: D:/software/VisualStudio/2022/Professional/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe Restored 0 package(s) from C:\Users\888\AppData\Local\vcpkg\archives in 122 us. Use --debug to see more details. Installing 1/1 hiredis:x64-windows@1.2.0... Building hiredis:x64-windows@1.2.0... -- Using cached redis-hiredis-v1.2.0.tar.gz CMake Error at scripts/cmake/vcpkg_extract_source_archive.cmake:92 (message): Could not find patch: 'fix-timeval.patch' Call Stack (most recent call first): scripts/cmake/vcpkg_extract_source_archive_ex.cmake:8 (vcpkg_extract_source_archive) scripts/cmake/vcpkg_from_github.cmake:113 (vcpkg_extract_source_archive_ex) ports/hiredis/portfile.cmake:1 (vcpkg_from_github) scripts/ports.cmake:203 (include) error: building hiredis:x64-windows failed with: BUILD_FAILED See https://learn.microsoft.com/vcpkg/troubleshoot/build-failures?WT.mc_id=vcpkg_inproduct_cli for more information. Elapsed time to handle hiredis:x64-windows: 32 ms 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+hiredis You can submit a new issue at: https://github.com/microsoft/vcpkg/issues/new?title=[hiredis]+Build+error+on+x64-windows&body=Copy%20issue%20body%20from%20E%3A%2Fvcpkg%2Fvcpkg-master%2Finstalled%2Fvcpkg%2Fissue_body.md 目录结构都改对了,但是始终报这个错
最新发布
04-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值