CMake Error at /opt/ros/humble/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message): ament_target_dependencies() the passed package name 'rclcpp' was not found
时间: 2023-08-10 09:09:37 浏览: 1093
这个错误提示说你的 CMake 找不到名为 'rclcpp' 的包。可能是因为你没有正确安装 ROS 或在 CMakeLists.txt 文件中没有正确声明依赖关系。
首先,请确保你已经正确地安装了 ROS 并设置好了环境变量。然后,检查你的 CMakeLists.txt 文件,是否正确地声明了依赖项。例如,如果你的包依赖于 rclcpp,应该在 CMakeLists.txt 文件中添加以下行:
```cmake
find_package(rclcpp REQUIRED)
```
然后,确保在使用 rclcpp 的任何地方都正确地链接该库。例如,在添加可执行文件时,应该包括以下行:
```cmake
add_executable(my_node src/my_node.cpp)
ament_target_dependencies(my_node rclcpp)
```
如果你已经执行了这些步骤,但仍然无法解决问题,请尝试重新编译你的代码并清除 CMake 缓存:
```bash
rm -rf build/
colcon build --symlink-install
```
这应该可以解决你的问题。
相关问题
CMake Error at /opt/rocm/hip/cmake/FindHIP.cmake:680 (add_library):NO SOURCES given to target: c10_hip
This error occurs when the add_library() function in the FindHIP.cmake file is unable to find any source files for the c10_hip target. The c10_hip target is used to build HIP-enabled libraries for PyTorch.
To fix this error, ensure that the source files for the c10_hip target are included in the appropriate directory and that the CMakeLists.txt file for the project includes the correct paths to these files.
You can also try updating your version of HIP or PyTorch to ensure that all necessary files are present and up-to-date. Additionally, ensure that your build environment is properly configured to support HIP and that all dependencies are installed correctly.
ubuntu16.04运行时报错CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1 CMake Error at bobac2_description/CMakeLists.txt:147 (add_dependencies): Cannot add target-level dependencies to non-existent target "bobac2_description_node". The add_dependencies works for top-level logical targets created by the add_executable, add_library, or add_custom_target commands. If you want to add file-level dependencies see the DEPENDS option of the add_custom_target and add_custom_command commands. CMake Error at bobac2_description/CMakeLists.txt:150 (target_link_libraries): Cannot specify link libraries for target "bobac2_description_node" which is not built by this project. -- Configuring incomplete, errors occurred! See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeOutput.log". See also "/home/bobac3/ros_workspace/build/CMakeFiles/CMakeError.log". Makefile:2796: recipe for target 'cmake_check_build_system' failed make: *** [cmake_check_build_system] Error 1
这个错误可能是因为在运行CMake时,找不到名为"bobac2_description_node"的目标。这可能是因为在CMakeLists.txt文件中没有正确地定义目标或源文件。您可以检查一下CMakeLists.txt文件中的目标和源文件是否正确定义。另外,您可以尝试清理并重新构建项目,以确保没有编译错误。您也可以查看CMakeError.log和CMakeOutput.log文件,以获取更多关于错误的详细信息。
阅读全文