网站头部固定,微信小程序是什么框架,网站建设网站优化,wordpress网站佣金推广Raspberry Pi3B之C/C开发环境搭建 1. 源由2. 环境搭建2.1 搭建C语言开发环境2.2 工程目录结构2.3 Makefile2.4 Demo (main.c) 3. 测试工程3.1 编译3.2 运行 4. 总结5. 参考资料 1. 源由
为了配合《Ardupilot开源飞控之FollowMe验证平台搭建》#xff0c;以及VINS-Fusion对于图… Raspberry Pi3B之C/C开发环境搭建 1. 源由2. 环境搭建2.1 搭建C语言开发环境2.2 工程目录结构2.3 Makefile2.4 Demo (main.c) 3. 测试工程3.1 编译3.2 运行 4. 总结5. 参考资料 1. 源由
为了配合《Ardupilot开源飞控之FollowMe验证平台搭建》以及VINS-Fusion对于图像和IMU时序的严格要求配合uav_splitter增加一个uav_mixer的agent部署在摄像头/飞控端。
该agent本次将采用C/C来实现采用传统Makefile作为工程管理文件便于后续的OpenIPC来做集成。
2. 环境搭建
工程开发先采用树莓派Raspberry Pi3B作为目标板搭建C语言开发环境并编写一个简单的工程结构来实现“Hello World”示例代码可以按照以下步骤进行。
2.1 搭建C语言开发环境
在树莓派上安装基本的开发工具包
sudo apt update
sudo apt install build-essential git tree注其中git用于开源项目代码管控tree更好的了解工程结构。
2.2 工程目录结构
使用以下的目录结构来组织工程文件
$ tree .
.
├── include
├── LICENSE
├── main.c
├── Makefile
├── README.md
└── src└── main.c2 directories, 5 filessrc/ 目录用于存放C语言的源代码。include/ 目录用于存放头文件如果有的话。Makefile 用于自动化构建过程。LICENSE 用于对于开源代码许可证建议用GPLv3.Readme.md 该文件采用了MarkDown的语言格式非常流行的文本版本管理语言格式。
2.3 Makefile
Makefile 会定义如何编译和链接C代码。以下是一个简单的示例
# Define the compiler
CC gcc# Define compiler options
CFLAGS -Wall -Iinclude# Define source directory and object directory
SRCDIR src
OBJDIR obj# Define the target executable name
TARGET helloworld# Define source files and object files
SRCS $(wildcard $(SRCDIR)/*.c)
OBJS $(SRCS:$(SRCDIR)/%.c$(OBJDIR)/%.o)# Default target
all: $(TARGET)# Link the object files to create the executable
$(TARGET): $(OBJS)$(CC) $(OBJS) -o $(TARGET)# Compile source files into object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)$(CC) $(CFLAGS) -c $ -o $# Create the object file directory
$(OBJDIR):mkdir -p $(OBJDIR)# Clean up generated files
clean:rm -rf $(OBJDIR) $(TARGET).PHONY: all clean2.4 Demo (main.c)
在 src/ 目录下创建一个 main.c 文件实现简单的Hello World程序
#include stdio.hint main() {printf(Hello, World!\n);return 0;
}3. 测试工程
3.1 编译
通过以下命令编译并运行程序
$ make # Compile the program3.2 运行
运行程序后应该在终端看到
$ ./helloworld # Run the generated executable
Hello, World!4. 总结
上述是一个Linux的C/C应用最为基础的工程。
在此基础上根据项目要求进行功能、特性的开发。
uav_mixer d1e6b13552a0811cc598309efeb40636bd23547f
5. 参考资料
【1】Linux应用程序之Helloworld入门