顺着这个思路,我也解决了这个问题,在这里贴一下Snipaste_2024-12-24_17-02-59.png
输入命令如下:
g++ first_ros2_node.cpp
-I /opt/ros/jazzy/include/rclcpp/
-I /opt/ros/jazzy/include/rcl_interfaces
-I /opt/ros/jazzy/include/rosidl_runtime_cpp
-I /opt/ros/jazzy/include/rosidl_runtime_c
-I /opt/ros/jazzy/include/service_msgs
-I /opt/ros/jazzy/include/builtin_interfaces
-I /opt/ros/jazzy/include/rosidl_typesupport_interface
-I /opt/ros/jazzy/include/rcutils/
-I /opt/ros/jazzy/include/rcl/
-I /opt/ros/jazzy/include/rmw
-I /opt/ros/jazzy/include/rcpputils
-I /opt/ros/jazzy/include/rcl_yaml_param_parser/
-I /opt/ros/jazzy/include/type_description_interfaces
-I /opt/ros/jazzy/include/rosidl_dynamic_typesupport
-I /opt/ros/jazzy/include/tracetools
-I /opt/ros/jazzy/include/libstatistics_collector
-I /opt/ros/jazzy/include/statistics_msgs
-I /opt/ros/jazzy/include/rosidl_typesupport_introspection_cpp
-L /opt/ros/jazzy/lib/
-lrclcpp -lrcutils