我正在冒险使用Visual编译一个CMake项目,目标是WSL 1。按照微软的教程在Visual中设置CMake项目并在WSL上调试运行良好。在将vcpkg安装到单独的vcpkg目录并将其集成到Visual中之后,当我尝试使用微软的软件包管理器安装和使用软件包时,情况就会改变。
一个简单的失败示例:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test)
find_package(protobuf CONFIG REQUIRED)带有以下错误消息:
CMake C:\test\CMakeLists.txt:5错误(find_package):无法找到由"protobuf“提供的具有下列任何名称之一的包配置文件 protobufConfig.cmake protobuf config.cmake 将安装前缀“非正式-sqlite3 3”添加到CMAKE_PREFIX_PATH或将"protobuf_DIR“设置到包含上述文件之一的目录中。如果"protobuf“提供了一个单独的开发包或SDK,请确保它已经安装。
我正在让Intellisense识别find_package,并建议安装软件包或将vcpkg命令复制到剪贴板。
CMake工具链文件指向WSL Debug配置设置中的“C:/vcpkg/script/buildsystems/vcpkg.cmake”文件。在Linux系统上安装vcpkg并将CMake工具链文件设置为相应的路径将创建完全相同的错误输出。
在终端中运行"vcpkg install protobuf:x64-linux“命令将创建以下输出:
Computing installation plan...
The following packages will be built and installed:
protobuf[core]:x64-linux -> 3.14.0#1
Detecting compiler hash for triplet x64-linux...
Error: while detecting compiler information:
The log content at C:\vcpkg\buildtrees\detect_compiler\stdout-x64-linux.log is:
-- Configuring x64-linux
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:108 (message):
Command failed: ninja -v
Working Directory: C:/vcpkg/buildtrees/detect_compiler/x64-linux-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\vcpkg\buildtrees\detect_compiler\config-x64-linux-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:319 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:128 (include)
Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.这并不奇怪,因为我不认为它能够在我的Windows机器上构建针对Linux的包。
我刚开始跨平台开发,我发现关于vcpkg + WSL的文档相当稀少。我是否正确地假设包应该由运行在Linux系统上的vcpkg来安装?还是需要在Windows上安装CMake才能使vcpkg在Windows端工作?
设置:
发布于 2021-02-11 11:00:11
我好像有点偏离轨道了。
安装在Windows机器上的vcpkg在Linux系统上是可访问的,就像实际的CMake项目是可访问的一样。将"CMAKE_TOOLCHAIN_FILE“变量设置为绝对”C:/vcpkg/CMAKE_TOOLCHAIN_FILE/buildsystems/vcpkg.cmake“路径被转换为CMAKE_TOOLCHAIN_FILE
缺少的步骤是在Linux系统上运行./bootstrap-vcpkg.sh脚本,以确保包可以由Linux系统上的vcpkg安装。
我还了解到,软件包必须通过运行vcpkg安装命令手动安装,因为没有通过CMake实现此操作的"build in“。
https://stackoverflow.com/questions/66146274
复制相似问题