ubuntu cv_bridge报错记录 Keywords: boost_python3Config.cmake boost_python3-config.cmake

文章描述了在Ubuntu20.04环境下使用cv_bridge时遇到的错误,涉及boost_python3包的配置文件缺失。解决方案是临时注释CMakeLists.txt中的find_package部分,以避免该问题。

ubuntu cv_bridge报错记录

解决方法来自Ubuntu20.04 出现 Could not find a package configuration file provided by “boost_python3“的参考解决方法,为了方便自己后续查看,再发一份。

报错来源于对cv_bridge进行catkin_make

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)
  cv_bridge/CMakeLists.txt:17 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/robot/tools/MYNT_EYE/S_SDK/build/CMakeFiles/CMakeOutput.log".
See also "/home/robot/tools/MYNT_EYE/S_SDK/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

将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()
### 正确使用 `boost_python3Config.cmake` 文件及其路径和配置方法 #### 1. 理解 `boost_python3Config.cmake` 的作用 `boost_python3Config.cmake` 是由 CMake 提供的一个模块化配置文件,用于简化 Boost.Python 库的集成过程。它能够自动检测并设置 Boost.Python 的头文件路径、库路径以及其他必要的编译选项[^4]。 --- #### 2. 获取 `boost_python3Config.cmake` 文件 通常情况下,在安装 Boost.Python 后,该文件会自动生成于指定的安装路径下的 `lib/cmake/boost_python3` 目录中。如果未找到此文件,则可能是因为安装过程中缺少某些必要参数或步骤。以下是生成此文件的关键操作: - **通过 Bootstrap 和 B2 构建 Boost** 使用以下命令构建 Boost 并启用 Python 支持: ```bash ./bootstrap.sh --with-libraries=python --with-python=/usr/bin/python3.7 --prefix=/home/boost/ ./b2 install ``` - **验证安装路径** 如果成功完成上述步骤,可以在 `/home/boost/lib/cmake/boost_python3` 中找到 `boost_python3Config.cmake` 文件[^1]。 --- #### 3. 配置 CMakeLists.txt 在项目的 `CMakeLists.txt` 文件中引入 `boost_python3Config.cmake` 及其依赖项的具体方式如下所示: ```cmake # 设置 Boost 根目录 (假设已安装到 /home/boost/) set(BOOST_ROOT "/home/boost") # 查找 Boost 组件 find_package(Boost REQUIRED COMPONENTS python3) # 添加 Boost_Python 到项目 if(Boost_FOUND AND Boost_PYTHON3_FOUND) message(STATUS "Found Boost and Boost::python3") add_executable(my_project main.cpp) target_include_directories(my_project PRIVATE ${Boost_INCLUDE_DIRS}) target_link_libraries(my_project PRIVATE Boost::python3) endif() ``` 注意:确保 `${Boost_INCLUDE_DIRS}` 和 `${Boost_LIBRARIES}` 已正确定义,并指向正确的 Boost 头文件和库位置[^2]。 --- #### 4. 自动查找 Python 路径 对于动态链接 Python 解释器的情况,可以利用 Python 内部工具获取所需的路径信息: ```python import sysconfig print(sysconfig.get_path('include')) # 输出 Python include 路径 print(sysconfig.get_path('stdlib')) # 输出 Python lib 路径 ``` 这些路径应被传递给 CMake 或手动添加至环境变量中以便正确解析[^3]。 --- #### 5. 常见错误处理 当遇到类似于 `Could not find a package configuration file provided by 'boost_python3'` 错误时,需确认以下几点: - 是否正确指定了 BOOST_ROOT; - 安装后的 `boost_python3Config.cmake` 文件是否存在目标路径下; - 若仍无法定位,尝试重新运行 b2 编译脚本以更新缺失组件。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值