ROS2-Jazzy编译功能包报错

0 阅读1分钟

系统:ubuntu24.04

ROS2:Jazzy(鱼香ros一键安装)

问题:colcon build 时报错:

CMake Error at CMakeLists.txt:12 (find_package):
 By not providing "Findbase_interfaces_demo.cmake" in CMAKE_MODULE_PATH this
 project has asked CMake to find a package configuration file provided by
 "base_interfaces_demo", but CMake did not find one.

Could not find a package configuration file provided by
 "base_interfaces_demo" with any of the following names:

    base_interfaces_demoConfig.cmake
    base_interfaces_demo-config.cmake

Add the installation prefix of "base_interfaces_demo" to CMAKE_PREFIX_PATH
 or set "base_interfaces_demo_DIR" to a directory containing one of the
 above files. If "base_interfaces_demo" provides a separate development
 package or SDK, be sure it has been installed.

失败尝试:

  1. 尝试更新列表sudo apt update然后安装sudo apt install base_interfaces_demo(无法定位软件包)

最终解决办法:

  • find / -name "base_interfaces_demo" 2>/dev/null

    找到所有相关文件,在我的系统里找到这个包在:/home/lihaoting/.local/share/Trash/files/install/**目录下有

  • 打开.bashrc文件(一般是隐藏的,在家目录下ctrl + h 就能显示)

  • 在末尾添加export CMAKE_PREFIX_PATH=/home/lihaoting/.local/share/Trash/files/install:$CMAKE_PREFIX_PATH并保存退出

  • 重新编译即可