[技术问答] FAQ_MA35D1_Add a New Recipe in Yocto

[复制链接]
 楼主| 七毛钱 发表于 2023-1-6 14:00 | 显示全部楼层 |阅读模式
此示例演示如何创建一个可以编译源代码并安装到MA35D1镜像的配置
1.在meta-ma35d1/precipes支持下创建一个名为helloworld的新文件夹
  • ~/shared/yocto/sources/meta-ma35d1/recipes-support$ mdkir helloworld
[color=rgb(51, 102, 153) !important]复制代码
2.在helloworld文件夹下创建一个名为files的新文件夹
  • ~/shared/yocto/sources/meta-ma35d1/recipes-support/hello$ mkdir files
[color=rgb(51, 102, 153) !important]复制代码
3.创建一个名为helloworld.C的C文件,其内容如下所示
  • #include <stdio.h>
  • int main()
  • {
  •     printf("Hello, World!\n");
  •     return 0;
  • }

[color=rgb(51, 102, 153) !important]复制代码
4.创建一个名为helloworld.bb的bb文件,其内容如下所示
  • SUMMARY = "Demo how to compile a C code and add to root filesystem"
  • LICENSE = "CLOSED"
  • SRC_URI = "file://helloworld.c \
  •       "
  • S = "${WORKDIR}"
  • do_compile() {
  •     ${CC} helloworld.c -o helloworld
  • }
  • do_install() {
  •     install -d ${D}/${bindir}
  •     install -m 0777 ${S}/helloworld ${D}${bindir}/helloworld
  • }
  • INSANE_SKIP_${PN} += "ldflags"
  • FILES_${PN} = "${bindir}"
[color=rgb(51, 102, 153) !important]复制代码
5.将配置添加到~/build/conf/local.conf
  • IMAGE_INSTALL_append += "  helloworld "

[color=rgb(51, 102, 153) !important]复制代码
6.重新编译镜像,helloworld将位于/usr/bin中


稳稳の幸福 发表于 2023-1-7 16:49 | 显示全部楼层
这个开发方法是用什么实现
您需要登录后才可以回帖 登录 | 注册

本版积分规则

375

主题

2621

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部

375

主题

2621

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部