基于yocto 添加自己应用程序

2022-07-08  本文已影响0人  jackniu_ae28
  1. 在_linux/develop/poky/meta-poky目录创建recipes-test 目录

2.目录结构如下:

recipes-test/
recipes-test/
└── hello
    ├── hello
    │   ├── hello.c
    │   └── Makefile
    └── hello.bb

3.编写 hello.bb 文件如下

CRIPTION = "Hello World Test"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://hello.c;md5=337c3657fbaf1381ff87f1cfbcd0389e"
PV = "1"
PR = "r0"


SRC_URI = "file://hello.c \
           file://Makefile \
          "

S = "${WORKDIR}"

do_compile () {
    make
}

do_install() {
        install -d ${D}${bindir}/
        install -m 0755 ${S}/hello ${D}${bindir}/
}

FILES_${PN} = "${bindir}/hello"

INSANE_SKIP_${PN} = "ldflags"
#For dev packages only
INSANE_SKIP_${PN}-dev = "ldflags"

4.编写Makefile 文件

hello:hello.o
        $(CC) -o hello hello.o

hello.o: hello.c
        $(CC) -c hello.c

.PHONY : clean
clearn:
        -rm -rf *.o

5.编写 hello.c

#include "stdio.h"
#include "stdlib.h"

int main()
{
        while(1)
        {
                fprintf(stderr, "HelloWorld");
                sleep(1);
        }
        return 0;
}

6.编译 hello

 source poky/oe-init-build-env
bitbake hello
上一篇 下一篇

猜你喜欢

热点阅读