上一篇用的是 cp 源 bitbake 中的 conf 和 classes 参数完成 hello world 的显示,相当于另外创建了一个新文件夹,搭建了一个新的 bitbake 环境来运行 hello world 。
这次打算用原本的环境通过 makefile 来完成 hello.c 的运行。
1.新建文件夹
mkdir recipes-test----mkdir hello----vim hello.c 和 vim Makefile
|--vim hello.bb
2.创建相关文件:
hello.c:
#include "stdio.h"
#include "stdlib.h"
int main()
{
while(1)
{
fprintf(stderr, "HelloWorld");
sleep(1);
}
return 0;
}
Makefile:
hello:hello.o
$(CC) -o hello hello.o
hello.o: hello.c
$(CC) -c hello.c
.PHONY : clean
clearn:
-rm -rf *.o
hello.bb:
DESCRIPTION = "gst plugins, v1sink"
LICENSE = "CLOSED"
SRCREV= "${AUTOREV}"
SRC_URI = "\
${REALTEK_GIT}/sdk/soc/realtek/rtkv1sink;protocol=${REALTEK_GIT_PROTOCOL};branch=${REALTEK_SDK_GIT_BRANCH} \
"
S = "${WORKDIR}/git"
LIC_FILES_CHKSUM = "file://hello.c;md5=c887acb828cf8aa8512e94eed3e729f0"
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"
hello.bb文件中我多加了前十行,用的是我自己电脑之前配置文件中的案例,和一些参考资料不一样。
3.运行:
先 bitbake -s | grep hello 查看一下 bitbake 能不能读取到我们新增的recipes,结果出现这两个就算可以的:
紧接着运行得到结果:
bitbake hello
这样子就是编译通过的!
参考资料:
Yocto新增一个hello程序_baidu_26866585的博客-CSDN博客_bitbake 添加一个应用程序