【问题标题】:Cannot add C file to Yocto Layer using bitbake无法使用 bitbake 将 C 文件添加到 Yocto 层
【发布时间】:2021-11-03 00:07:55
【问题描述】:

我有一个 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 执行时,终端显示 threads 无法构建并遇到错误:

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 文件(将其添加为层)。我无法构建相同的图像。

我会很感激一些帮助和见解!

【问题讨论】:

    标签: multithreading embedded-linux yocto bitbake yocto-recipe


    【解决方案1】:

    您的食谱存在多个问题:

    • 您的 do_compile 命令未指明在哪里可以找到您的 .c 文件
    • 您应该使用${CC} 而不是$(CC)
    • lpthread 不以和结尾 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 unbuildable:

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

    这里有一些选择:

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

    【讨论】:

    • 感谢您的意见!我做了你提到的更改并编译。 bitbake example 没有显示任何错误,但是,bitbake core-image-minimal 给出的错误与以前相同,即 threads 无法构建。我还能做错什么?
    • @Sajil 我更新了我的答案,希望对你有所帮助。
    • 感谢您的指导!我实施了您的所有更正,并且以编程方式我做对了。但是,后来我发现正在为IMAGE_INSTALL 编辑的 .conf 文件不是我应该更改的文件。有 3 个构建文件夹,我编辑了错误的一个!非常感谢!
    猜你喜欢
    • 2018-08-29
    • 2021-11-04
    • 1970-01-01
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 2018-07-17
    • 1970-01-01
    相关资源
    最近更新 更多