当前位置: 首页 > news >正文

使用make编译ROS2节点

有没有觉得用g++

编译节点无比的麻烦,的确是这样子,为此先行者们发明了一个叫做make的批处理工具,我们可以将g++的指令写成脚本,就可以通过make自动的调用脚本完成操作。

1.安装make

sudo apt install make

2.编写Makefile

d2lros2/d2lros2/chapt2/basic下新建Makefile,然后将上面的g++编译指令用下面的形式写到Makefile里。

build:g++ first_ros2_node.cpp \-I/opt/ros/humble/include/rclcpp
/ \-I /opt/ros/humble/include/rcl/ \-I /opt/ros/humble/include/rcutils
/ \-I /opt/ros/humble/include/rmw
 \-I /opt/ros/humble/include/rcl_yaml_param_parser
/ \-I /opt/ros/humble/include/rosidl_runtime_c
 \-I /opt/ros/humble/include/rosidl_typesupport_interface
 \-I /opt/ros/humble/include/rcpputils
 \-I /opt/ros/humble/include/builtin_interfaces
 \-I /opt/ros/humble/include/rosidl_runtime_cpp
 \-I /opt/ros/humble/include/tracetools
 \-I /opt/ros/humble/include/rcl_interfaces
 \-I /opt/ros/humble/include/libstatistics_collector
 \-I /opt/ros/humble/include/statistics_msgs
 \-L /opt/ros/humble/lib/ \-lrclcpp -lrcutils \-o first_node# 顺便小鱼加个clean指令,用来删掉first_node
clean:rm first_node

3. 编译

在Makefile同级目录输入

make build

可以看到make指令调用了脚本里的build下的指令,对代码进行了编译。同级目录下也产生了first_node可执行文件(绿色代表可执行)。

使用make clean指令即可删掉first_node节点。

4.运行测试

./first_node

新开终端

ros2 node list

http://www.lryc.cn/news/582027.html

相关文章:

  • 如果让计算机理解人类语言- Word2Vec(Word to Vector,2013)
  • 利用英译法案例演示RNN中的注意力机制(基于PyTorch)
  • 超越存在性检查:掌握Linux中`ls`命令的终极指南
  • .net core mvc部署到win10本地的Ubuntu上
  • 【Linux | 网络】网络基础
  • 多模式编译器——vim的使用
  • FastMCP:用于构建MCP服务器的开源Python框架
  • UE 材质 变体 概念
  • C++11标准库算法:深入理解std::none_of
  • Pandas 学习教程
  • T01_神经网络
  • 【python实用小脚本-130】基于 Python 的 HTML 到 Markdown 转换工具:实现高效文档格式转换
  • 钉钉企业内部机器人实现单聊会话互动开发指南
  • 【LeetCode 热题 100】234. 回文链表——快慢指针+反转链表
  • TypeScript 基础与类型系统详解:从入门到实践
  • TB62216FTG,TB62216FNG东芝BiCD集成电路硅单片,PWM斩波型电机驱动集成电路
  • 【Chrome】‘Good助手‘ 扩展程序使用介绍
  • 【操作系统】页面置换
  • OpenWebUI(2)源码学习-后端retrieval检索模块
  • vulnhub靶机渗透:PWNLAB: INIT
  • 海外短剧系统开发:PC端与H5端的全栈实践与深度解析
  • Java-66 深入浅出 分布式服务 Netty详解 EventLoop
  • [特殊字符] Excel 读取收件人 + Outlook 批量发送带附件邮件 —— Python 自动化实战
  • 嵌入式硬件中电容的基本原理与实现详解02
  • Excel 的多线程特性
  • 线程安全的单例模式与读者写者问题
  • WebRTC与RTMP
  • GPT5完全多模态架构拆解:实时视频生成如何颠覆内容创作
  • 什么是去中心化 AI?区块链驱动智能的初学者指南
  • 【C++指南】STL queue 完全解读(一):原理剖析与实战应用