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
安装库依赖的时候,也值得都安装一下