紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ROS2入门篇第3章-自定义接口RCLCPP实战colcon build失败,找不到功能包
-
一直按着鱼哥的教材走的,这是colcon build之后终端显示的错误,好像是找不到example_ros2_interfaces这个功能包,希望大佬帮解决一下
gaozhihao@gaozhihao-virtual-machine:~/Desktop/d2lros2/chapt3/chapt3_ws$ colcon build --packages-up-to example_interfaces_rclcpp Starting >>> example_interfaces_rclcpp --- stderr: example_interfaces_rclcpp CMake Error at CMakeLists.txt:11 (find_package): By not providing "Findexample_ros2_interfaces.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "example_ros2_interfaces", but CMake did not find one. Could not find a package configuration file provided by "example_ros2_interfaces" with any of the following names: example_ros2_interfacesConfig.cmake example_ros2_interfaces-config.cmake Add the installation prefix of "example_ros2_interfaces" to CMAKE_PREFIX_PATH or set "example_ros2_interfaces_DIR" to a directory containing one of the above files. If "example_ros2_interfaces" provides a separate development package or SDK, be sure it has been installed. gmake: *** [Makefile:308:cmake_check_build_system] 错误 1 --- Failed <<< example_interfaces_rclcpp [0.85s, exited with code 2] Summary: 0 packages finished [1.20s] 1 package failed: example_interfaces_rclcpp 1 package had stderr output: example_interfaces_rclcpp
-
你能提供以下你的cmake 文件吗?
-
cmake_minimum_required(VERSION 3.8) project(example_interfaces_rclcpp) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(example_ros2_interfaces REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # comment the line when a copyright and license is added to all source files set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # comment the line when this package is in a git repo and when # a copyright and license is added to all source files set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_package() add_executable(example_interfaces_robot_01 src/example_interfaces_robot_01.cpp) target_include_directories(example_interfaces_robot_01 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>) target_compile_features(example_interfaces_robot_01 PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 ament_target_dependencies( example_interfaces_robot_01 "rclcpp" "example_ros2_interfaces" ) install(TARGETS example_interfaces_robot_01 DESTINATION lib/${PROJECT_NAME}) add_executable(example_interfaces_control_01 src/example_interfaces_control_01.cpp) target_include_directories(example_interfaces_control_01 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>) target_compile_features(example_interfaces_control_01 PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 ament_target_dependencies( example_interfaces_control_01 "rclcpp" "example_ros2_interfaces" ) install(TARGETS example_interfaces_control_01 DESTINATION lib/${PROJECT_NAME})
-
@1597195629 在 ROS2入门篇第3章-自定义接口RCLCPP实战colcon build失败,找不到功能包 中说:
ament_package()
这句话放到最后,这句话前的指令才会被ros2认可
-
@杜守钰 uu你解决了嘛 我也是同样的问题 鱼哥说的
ament_package()
放在cmake文件的最后我依旧有同样的报错 而且我看视频里面是在该行代码之后编写的需要添加的代码 依旧colcon build成功了TT
-
@2937817639 可以试试用SET({对应接口}_DIR /yourpath/)的方式试试,原因应该是找不到接口包的路径
-
此回复已被删除!