找不到 Boost(缺少:python3)(找到版本“1.76.0”)- CMake Windows

Lor*_*ora 4 boost cmake windows-10 ros2

当尝试从 ros2 编译cv_bridge时,我需要帮助解决这个 cmake boost python3 find 问题,它使用名为colcon的构建工具,然后使用 CMake。colcon 构建错误消息:

> colcon build --symlink-install --merge-install
...    
--- stderr: cv_bridge
    CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find Boost (missing: python3) (found version "1.76.0")
    Call Stack (most recent call first):
      C:/Program Files/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
      C:/Program Files/CMake/share/cmake-3.22/Modules/FindBoost.cmake:2360 (find_package_handle_standard_args)
      CMakeLists.txt:32 (find_package)
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

  • 安装不同版本的boost:1.58、1.67、1.76
  • 将 cv_bridge 的 CMakeLists.txt 中 boost 库的路径添加到 Boost_INCLUDE_DIRS:
     if(NOT ANDROID)
          find_package(PythonLibs)
          list(APPEND Boost_INCLUDE_DIRS "C:/Program Files/boost/boost_1_76_0")
          list(APPEND Boost_INCLUDE_DIRS "C:/Program Files/boost/boost_1_76_0/stage/lib")
Run Code Online (Sandbox Code Playgroud)
  • 重命名libboost_python38-vc142-mt-gd-x64-1_76.liblibboost_python38.liblibboost_python3.lib
  • 使用bootstrap.batb2从源代码编译 Boost或使用 zip 文件安装。
  • 在这里和其他地方寻找答案,这导致我尝试了上面的事情

我已经没有想法了,请提供任何帮助,将不胜感激!

Omk*_*agi 5

我在 Fedora 上编译 ros noetic 时遇到了类似的问题。它能够找到,Boost 1.76.0所以我认为问题应该出在 python 组件上。我猜是找不到合适的libboost_python版本。因此,当我检查该库时,我在以下位置找到了它:/usr/lib64/libboost_python310.so。所以我更新了cv_bridge/CMakeLists.txt专门使用 3.10 版本:

if(NOT ANDROID)
  find_package(PythonLibs)

  if(PYTHONLIBS_VERSION_STRING VERSION_LESS "3.8")
    # Debian Buster
    find_package(Boost REQUIRED python37)
  else()
    # Ubuntu Focal
    
    # Because I am using python 3.10 I updated
    # this line. If you are using a version less
    # than 3.8, then update the previous line

    # Updated line
    find_package(Boost REQUIRED python310)
  endif()
else()
find_package(Boost REQUIRED)
endif()
Run Code Online (Sandbox Code Playgroud)

将其设置为专门查找 3.10 版本解决了该问题,并且我能够编译。

编辑:没有意识到问题是针对 Windows 平台的,但这个答案可能仍然有帮助