欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > 【Linux快速入门(二)】Linux与ROS学习之编译基础(make编译)

【Linux快速入门(二)】Linux与ROS学习之编译基础(make编译)

2025/7/2 5:56:30 来源:https://blog.csdn.net/2203_75993546/article/details/142905251  浏览:    关键词:【Linux快速入门(二)】Linux与ROS学习之编译基础(make编译)

目录

零.前置篇章 

一.make的由来

二.安装make        

三.编写Makefile

四.编译运行

五.删除可执行文件


零.前置篇章 

  1.  第一篇【Linux快速入门】Linux与ROS学习之编译基础(gcc编译)_linux+ros-CSDN博客

一.make的由来

        "make"是一个用于自动化构建软件的工具,通常用于编译和构建程序。当你运行make命令时,make工具会查找当前目录下的Makefile文件,该文件包含了编译程序所需的指令和规则。

        make起初是人们为了简化g++编译而发明出来的批处理工具,通过其自动调用指令而进行编译。

二.安装make        

sudo apt install make

三.编写Makefile

        进入到d2lros2/d2lros2/chapt2/basic下使用vim新建Makefile。

        然后将上一篇中的的g++编译指令用下面的形式写到Makefile里(最好要熟悉或者会使用基础的vim指令)。

build:g++ first_ros2_node.cpp \-I/opt/ros/jazzy/include/rclcpp/ \-I /opt/ros/jazzy/include/rcl/ \-I /opt/ros/jazzy/include/rcutils/ \-I /opt/ros/jazzy/include/rmw \-I /opt/ros/jazzy/include/rcl_yaml_param_parser/ \-I /opt/ros/jazzy/include/rosidl_runtime_c \-I /opt/ros/jazzy/include/rosidl_typesupport_interface \-I /opt/ros/jazzy/include/rcpputils \-I /opt/ros/jazzy/include/builtin_interfaces \-I /opt/ros/jazzy/include/rosidl_runtime_cpp \-I /opt/ros/jazzy/include/tracetools \-I /opt/ros/jazzy/include/rcl_interfaces \-I /opt/ros/jazzy/include/libstatistics_collector \-I /opt/ros/jazzy/include/statistics_msgs \-I /opt/ros/jazzy/include/service_msgs/ \-I /opt/ros/jazzy/include/type_description_interfaces/ \-I /opt/ros/jazzy/include/rosidl_dynamic_typesupport/ \-I /opt/ros/jazzy/include/rosidl_typesupport_introspection_cpp/ \-L /opt/ros/jazzy/lib/ \-lrclcpp -lrcutils  \-o first_node#编译执行完后立刻删除first_node
clean:rm first_node

四.编译运行

        键入以下命令即可编译生成可执行文件:

make build

运行该文件:

./first_node

开启新终端,可查看ros节点列表:

ros2 node list

 

五.删除可执行文件

make clean

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词