0

我有一个 C 文件二进制文件作为自定义层添加到 yocto 并在 qemu 中运行。我已经使用创建图层bitbake-layers create-layer meta-custLayer并使用bitbake-layers add-layer meta-custLayer. meta-custLayer 的文件树如下:
文件树

example_0.1.bb文件具有以下内容:

SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://threading.c"

S = "${WORKDIR}"
TARGET_CC_ARCH += "${LDFLAGS}"

do_compile(){
    $(CC) threading.c -o threads -lpthreads
}


do_install(){
    install -d ${D}${bindir}
    install -m 0755 threads
${D}${bindir}s
}

执行命令时bitbake example,输出如下:

ERROR: example-0.1-r0 do_compile: Execution of '/home/sajil/edm_yocto/sources/poky/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_compile.1806553' failed with exit code 127:
/home/sajil/edm_yocto/sources/poky/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_compile.1806553: 99: CC: not found
/home/sajil/edm_yocto/sources/poky/build/tmp/work/core2-64-poky-linux/example/0.1-r0/temp/run.do_compile.1806553: 99: threading.c: not found
WARNING: exit code 127 from a shell command.

执行时bitbake core-image-minimal,终端显示线程不可构建并遇到错误:

ERROR: Nothing RPROVIDES 'threads' (but /home/sajil/edm_yocto/sources/poky/meta/recipes-core/images/core-image-minimal.bb RDEPENDS on or otherwise requires it)
NOTE: Runtime target 'threads' is unbuildable, removing...
Missing or unbuildable dependency chain was: ['threads']
ERROR: Required build target 'core-image-minimal' has no buildable providers.
Missing or unbuildable dependency chain was: ['core-image-minimal', 'threads']

我检查了自定义层目录的路径,是正确的。我对我面临的错误一无所知。

现在我的任务是在 QEMU 上运行 C 文件(将其添加为层)。我无法为此构建图像。

我将不胜感激一些帮助和见解!

4

1 回答 1

2

您的食谱有多个问题:

  • 您的do_compile命令没有指明在哪里可以找到您的 .c 文件
  • 你应该使用${CC}而不是$(CC)
  • lpthread不以 and 结尾s
do_compile() {
    ${CC} ${S}/threading.c -o ${S}/threads -lpthread
}
  • do_install没有提供二进制文件的正确路径:
do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/threads ${D}${bindir}
}
  • 最后,您应该填充包:
FILES_${PN} = "${bindir}"

编辑关于threads不可建造的:

threads是不可构建的,因为配方没有提到包是threads.

在这里,您有一些选择:

  • 将您的食谱重命名为threads_0.1.bb(我建议您使用不太通用的名称)
  • 在你的食谱中使用PACKAGES变量。您还需要修改FILES_*变量。(如果您是 Yocto 新手,会有点复杂)
  • IMAGE_INSTALL += "threads"使用当前配方名称,并将IMAGE_INSTALL += "example"
于 2021-09-06T08:01:10.947 回答