我需要帮助解决这个问题:当尝试从ROS2编译cv_bridge时,遇到了cmake boost python3查找问题。ROS2使用名为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)
我尝试过的方法:
- 安装不同版本的boost:1.58、1.67、1.76
- 在cv_bridge的CMakeLists.txt中将Boost_INCLUDE_DIRS添加到boost库的路径中:
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")
- 将
libboost_python38-vc142-mt-gd-x64-1_76.lib
重命名为libboost_python38.lib
和libboost_python3.lib
- 使用 bootstrap.bat 和 b2 编译Boost源代码或者使用zip文件安装。
- 在这里和其他地方寻求答案,尝试了上述方法。
我已经没有更多的想法了,请大家帮帮我!
find_package
来定位 Boost。在使用find_package
之前设置Boost_ROOT
;或者使用 b2(.\b2 ... "--prefix=some/path" ... install
)将安装 Boost 的目录添加到CMAKE_PREFIX_PATH
中。find_package(Boost REQUIRED COMPONENTS python CONFIG)
。此外,请注意自 CMake 3.12 起,FindPythonLibs 模块 已被弃用。 - fabianC:\Program Files\boost\boost_1_76_0
添加到CMAKE_PREFIX_PATH
也不起作用。配置版本也不行。由于不存在FindPython3Config.cmake
,配置版本无法找到它。我在这个线程中发现,似乎自Boost 1.70以来,cmake配置停止在指定的位置查找... - Lora