Ubuntu20.04 出现 Could not find a package configuration file provided by “boost_python3“的参考解决方法

写在前面

笔者的环境:
Ubuntu 20.04,ROS-noetic.
下面是自己的解决方法,供朋友们参考。

一、问题描述

自己是在编译ROS程序时,其中该程序涉及到vision_opencv/cv_bridge,出现如下报错:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package):
  Could not find a package configuration file provided by "boost_python3"
  (requested version 1.71.0) with any of the following names:

    boost_python3Config.cmake
    boost_python3-config.cmake

  Add the installation prefix of "boost_python3" to CMAKE_PREFIX_PATH or set
  "boost_python3_DIR" to a directory containing one of the above files.  If
  "boost_python3" provides a separate development package or SDK, be sure it
  has been installed.
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
  /usr/share/cmake-3.16/Modules/FindBoost.cmake:443 (find_package)
  CMakeLists.txt:17 (find_package)

报错截图如下:
在这里插入图片描述

二、解决方法

出现这种情况的原因主要是

修改方法:
vision_opencv/cv_bridge/CMakeLists.txt 中的如下语句:

if(NOT ANDROID)
  find_package(PythonLibs)
  if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
    find_package(Boost REQUIRED python)
  else()
    find_package(Boost REQUIRED python3)
  endif()
else()
find_package(Boost REQUIRED)
endif()

修改为:

if(NOT ANDROID)
  find_package(PythonLibs)
  # if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
    find_package(Boost REQUIRED python)
  # else()
  #   find_package(Boost REQUIRED python3)
  # endif()
else()
find_package(Boost REQUIRED)
endif()

参考链接

[1] ethz-asl/maplab. Error with boost dependency #368 [EB/OL]. https://github.com/ethz-asl/kalibr/issues/368, 2021-03-02/2023-01-16.
[2] (该博客的方法自己试验未成功) 飞同学. boost_python3 [EB/OL]. https://blog.csdn.net/z1872385/article/details/124782647, 2022-05-15/2023-01-16.

猜你喜欢

转载自blog.csdn.net/qq_39779233/article/details/128699472