紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ros2humble自定义消息类型报错
-
报错:
gmake[2]: *** [CMakeFiles/my_package__rosidl_typesupport_fastrtps_c.dir/build.make:123:CMakeFiles/my_package__rosidl_typesupport_fastrtps_c.dir/rosidl_typesupport_fastrtps_c/my_package/msg/detail/my_msg__type_support_c.cpp.o] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:239:CMakeFiles/my_package__rosidl_typesupport_fastrtps_c.dir/all] 错误 2 gmake[1]: *** 正在等待未完成的任务.... gmake[2]: *** [CMakeFiles/my_package__rosidl_typesupport_fastrtps_cpp.dir/build.make:123:CMakeFiles/my_package__rosidl_typesupport_fastrtps_cpp.dir/rosidl_typesupport_fastrtps_cpp/my_package/msg/detail/dds_fastrtps/my_msg__type_support.cpp.o] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:291:CMakeFiles/my_package__rosidl_typesupport_fastrtps_cpp.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< my_package [2.20s, exited with code 2] Summary: 0 packages finished [2.59s] 1 package failed: my_package 1 package had stderr output: my_package
cmakelist.txt:
cmake_minimum_required(VERSION 3.8) project(my_package) if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() # find dependencies # uncomment the following section in order to fill in # further dependencies manually. # find_package(<dependency> REQUIRED) find_package(std_msgs REQUIRED) find_package(rosidl_default_generators REQUIRED) rosidl_generate_interfaces(${PROJECT_NAME} "msg/MyMsg.msg" DEPENDENCIES std_msgs ) ament_export_dependencies(rosidl_default_runtime) ament_package()
package.xml:
<?xml version="1.0"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> <package format="3"> <name>my_package</name> <version>0.0.1</version> <description>TODO: Package description</description> <maintainer email="123456@qq.com">henglin</maintainer> <license>Apache License 2.0</license> <buildtool_depend>rosidl_default_generators</buildtool_depend> <build_depend>std_msgs</build_depend> <exec_depend>rosidl_default_runtime</exec_depend> <exec_depend>std_msgs</exec_depend> <member_of_group>rosidl_interface_packages</member_of_group> <test_depend>ament_lint_auto</test_depend> <test_depend>ament_lint_common</test_depend> <export> <depend>std_msgs</depend> <depend>rosidl_default_generators</depend> </export> </package>
msg文件:
string publisher_id float64 x float64 y float64 z
-
-
@1941548611 把完整报错贴出来
-
原报错非常长,好几万字符,这是部分报错:
/home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_c/more_interfaces/msg/detail/key_board_value__functions.c: In function ‘more_interfaces__msg__KeyBoardValue__create’: /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_c/more_interfaces/msg/detail/key_board_value__functions.c:91:3: warning: implicit declaration of function ‘memset’ [-Wimplicit-function-declaration] 91 | memset(msg, 0, sizeof(more_interfaces__msg__KeyBoardValue)); | ^~~~~~ /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_c/more_interfaces/msg/detail/key_board_value__functions.c:12:1: note: include ‘<string.h>’ or provide a declaration of ‘memset’ 11 | #include "rcutils/allocator.h" +++ |+#include <string.h> 12 | /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_c/more_interfaces/msg/detail/key_board_value__functions.c:91:3: warning: incompatible implicit declaration of built-in function ‘memset’ [-Wbuiltin-declaration-mismatch] 91 | memset(msg, 0, sizeof(more_interfaces__msg__KeyBoardValue)); | ^~~~~~ /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_c/more_interfaces/msg/detail/key_board_value__functions.c:91:3: note: include ‘<string.h>’ or provide a declaration of ‘memset’ In file included from /usr/include/stdint.h:26, from /usr/lib/gcc/x86_64-linux-gnu/11/include/stdint.h:9, from /opt/ros/humble/include/rmw/features.h:24, from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586, from /usr/include/c++/11/utility:68, from /usr/include/c++/11/algorithm:60, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_cpp/more_interfaces/msg/detail/key_board_value__struct.hpp:8, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/key_board_value__rosidl_typesupport_fastrtps_cpp.hpp:11, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/dds_fastrtps/key_board_value__type_support.cpp:4: /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:74:17: error: missing binary operator before token "(" 74 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X) | ^ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:80:17: error: missing binary operator before token "(" 80 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__ | ^ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:97:17: error: missing binary operator before token "(" 97 | #if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC2X) | ^ In file included from /usr/lib/gcc/x86_64-linux-gnu/11/include/stdint.h:9, from /opt/ros/humble/include/rmw/features.h:24, from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586, from /usr/include/c++/11/utility:68, from /usr/include/c++/11/algorithm:60, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_cpp/more_interfaces/msg/detail/key_board_value__struct.hpp:8, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/key_board_value__rosidl_typesupport_fastrtps_cpp.hpp:11, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/dds_fastrtps/key_board_value__type_support.cpp:4: /usr/include/stdint.h:276:17: error: missing binary operator before token "(" 276 | #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) | ^ In file included from /usr/include/stdio.h:27, from /opt/ros/humble/include/rcutils/rcutils/testing/fault_injection.h:18, from /opt/ros/humble/include/rcutils/rcutils/macros.h:146, from /opt/ros/humble/include/rcutils/rcutils/allocator.h:28, from /opt/ros/humble/include/rmw/features.h:26, from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586, from /usr/include/c++/11/utility:68, from /usr/include/c++/11/algorithm:60, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_cpp/more_interfaces/msg/detail/key_board_value__struct.hpp:8, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/key_board_value__rosidl_typesupport_fastrtps_cpp.hpp:11, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/dds_fastrtps/key_board_value__type_support.cpp:4: /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:74:17: error: missing binary operator before token "(" 74 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || __GLIBC_USE (ISOC2X) | ^ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:80:17: error: missing binary operator before token "(" 80 | #if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__ | ^ /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:97:17: error: missing binary operator before token "(" 97 | #if __GLIBC_USE (IEC_60559_FUNCS_EXT) || __GLIBC_USE (ISOC2X) | ^ In file included from /opt/ros/humble/include/rcutils/rcutils/testing/fault_injection.h:18, from /opt/ros/humble/include/rcutils/rcutils/macros.h:146, from /opt/ros/humble/include/rcutils/rcutils/allocator.h:28, from /opt/ros/humble/include/rmw/features.h:26, from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586, from /usr/include/c++/11/utility:68, from /usr/include/c++/11/algorithm:60, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_cpp/more_interfaces/msg/detail/key_board_value__struct.hpp:8, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/key_board_value__rosidl_typesupport_fastrtps_cpp.hpp:11, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/dds_fastrtps/key_board_value__type_support.cpp:4: /usr/include/stdio.h:136:17: error: missing binary operator before token "(" 136 | #if __GLIBC_USE (ISOC2X) | ^ /usr/include/stdio.h:306:43: error: missing binary operator before token "(" 306 | #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) | ^ /usr/include/stdio.h:387:17: error: missing binary operator before token "(" 387 | #if __GLIBC_USE (LIB_EXT2) | ^ In file included from /usr/include/stdio.h:430, from /opt/ros/humble/include/rcutils/rcutils/testing/fault_injection.h:18, from /opt/ros/humble/include/rcutils/rcutils/macros.h:146, from /opt/ros/humble/include/rcutils/rcutils/allocator.h:28, from /opt/ros/humble/include/rmw/features.h:26, from /usr/include/x86_64-linux-gnu/c++/11/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/c++config.h:586, from /usr/include/c++/11/utility:68, from /usr/include/c++/11/algorithm:60, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_generator_cpp/more_interfaces/msg/detail/key_board_value__struct.hpp:8, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/key_board_value__rosidl_typesupport_fastrtps_cpp.hpp:11, from /home/henglin/view_he/project_6/QtWidgetsApplication1/build/more_interfaces/rosidl_typesupport_fastrtps_cpp/more_interfaces/msg/detail/dds_fastrtps/key_board_value__type_support.cpp:4: /usr/include/x86_64-linux-gnu/bits/floatn.h:30:22: error: missing binary operator before token "(" 30 | ? __GNUC_PREREQ (4, 3) \ | ^
-
@小鱼 都是一堆标准库未声明,找不到定义之类的问题
-
@1941548611 重新换个系统或环境看看吧,目前我也看不出具体问题,感觉和上下文环境有关系
-
@小鱼 现在的报错情况就是,只有自定义消息类型功能用不了,其他ros2功能正常;报错中显示了gcc的头文件有问题,单独使用头文件编译都正常,生成可执行文件,现在就完全不知道啥情况,单独使用没问题,一起用就有问题
-
@1941548611 考虑还是环境问题,重装麻烦可以试试docker中构建
-
同问 解决了嘛?