使用自定义配方构建错误

问题描述 投票:0回答:2

由于我是 yocto 的新手,我一直在尝试使用简单的 C 程序制作一个配方,该程序使用 makefile 生成二进制文件。创建食谱后,我收到以下错误

Command '['aarch64-poky-linux-objcopy', '--only-keep-debug', '/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/hello_shell', '/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/.debug/hello_shell']' returned non-zero exit status 1.
Subprocess output:aarch64-poky-linux-objcopy: Unable to recognise the format of the input file `/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/hello_shell'

ERROR: Logfile of failure stored in: /home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/temp/log.do_package.15925
ERROR: Task (/home/bhargav/RPI3/Build/meta-shell/recipes-myshell/myshell/myshell_0.1.bb:do_package) failed with exit code '1'

这是我的食谱

SUMMARY = "bitbake-layers recipe"
DESCRIPTION = "Recipe created by bitbake-layers"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=6e0eb429dbab531d0874038360a879b9"

SRCREV = "ce92f43aea4f5ea32858892f446084ea9f2b2a7f"
SRC_URI = "git://github.com/bhargavthriler/simple_shell.git"

S = "${WORKDIR}/git"

FILES_${PN} += "${libdir}/"  

do_compile() {
    make
}

TARGET_CC_ARCH += "${LDFLAGS}"

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

这是我的 makefile

SRCS = $(wildcard *.c)

CC = gcc

OBJ_NAME = hello_shell

all : ${SRCS}
    $(CC) $(SRCS) -o $(OBJ_NAME)

clean :
    rm $(OBJ_NAME)

我面临构建错误。我正在用元树莓派构建它 我的完整构建

bhargav@bhargav-Lenovo-Legion-Y540-15IRH-PG0:~/RPI3/Build/poky/build (master)$ bitbake rpi-basic-image
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 2876 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "raspberrypi3-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.1"
TUNE_FEATURES        = "aarch64 cortexa53 crc"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       = "master:2e11d97b6c95e89aa1f9d3603a966c94c442469e"
meta-raspberrypi     = "master:27d0016b6b7634ea2abf26a06b1ab8071fbdb0d5"
meta-oe              = "master:679bb4912613f3860e8527557602251e5e5f2c41"
meta-python2         = "master:2684086f91e7074324081196c8a5f9945d39650e"
meta-shell           = "master:81fd3448f603a56409389247443439cad4fdaa67"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:02
Sstate summary: Wanted 111 Found 111 Missed 0 Current 1304 (100% match, 100% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 3725 tasks of which 3725 didn't need to be rerun and all succeeded.
bhargav@bhargav-Lenovo-Legion-Y540-15IRH-PG0:~/RPI3/Build/poky/build (master)$ bitbake myshell
Loading cache: 100% |########################################################################################################################################################################| Time: 0:00:00
Loaded 2876 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "aarch64-poky-linux"
MACHINE              = "raspberrypi3-64"
DISTRO               = "poky"
DISTRO_VERSION       = "3.1"
TUNE_FEATURES        = "aarch64 cortexa53 crc"
TARGET_FPU           = ""
meta                 
meta-poky            
meta-yocto-bsp       = "master:2e11d97b6c95e89aa1f9d3603a966c94c442469e"
meta-raspberrypi     = "master:27d0016b6b7634ea2abf26a06b1ab8071fbdb0d5"
meta-oe              = "master:679bb4912613f3860e8527557602251e5e5f2c41"
meta-python2         = "master:2684086f91e7074324081196c8a5f9945d39650e"
meta-shell           = "master:81fd3448f603a56409389247443439cad4fdaa67"

Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:00
Sstate summary: Wanted 12 Found 8 Missed 4 Current 123 (66% match, 97% complete)
NOTE: Executing Tasks
ERROR: myshell-0.1-r0 do_package: Fatal errors occurred in subprocesses:
Command '['aarch64-poky-linux-objcopy', '--only-keep-debug', '/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/hello_shell', '/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/.debug/hello_shell']' returned non-zero exit status 1.
Subprocess output:aarch64-poky-linux-objcopy: Unable to recognise the format of the input file `/home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/package/usr/bin/hello_shell'

ERROR: Logfile of failure stored in: /home/bhargav/RPI3/Build/poky/build/tmp/work/aarch64-poky-linux/myshell/0.1-r0/temp/log.do_package.15925
ERROR: Task (/home/bhargav/RPI3/Build/meta-shell/recipes-myshell/myshell/myshell_0.1.bb:do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 538 tasks of which 537 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/bhargav/RPI3/Build/meta-shell/recipes-myshell/myshell/myshell_0.1.bb:do_package
Summary: There was 1 ERROR message shown, returning a non-zero exit code.
bhargav@bhargav-Lenovo-Legion-Y540-15IRH-PG0:~/RPI3/Build/poky/build (master)$

我犯了什么错误?

linux cross-compiling yocto bitbake meta-raspberrypi
2个回答
3
投票

发生错误是因为 makefile 中有

CC = gcc
,它指向
host
中的编译器。这会覆盖 yocto 设置的
CROSS_COMPILER
。因此,您构建的二进制文件
hello_shell
适用于主机(ELF 64位LSB可执行文件,x86-64),在使用
aarch64-poky-linux-objcopy

时会引发错误

尝试从 makefile 中删除

CC = gcc


0
投票

您可能需要在 .bbappend 中执行以下操作:

inherit externalsrc
inherit autotools

EXTRA_OEMAKE = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${TARGET_PREFIX}gcc ${TOOLCHAIN_OPTIONS}" V=1'
EXTRA_OEMAKE += ' HOSTCC="${BUILD_CC}'
EXTRA_OEMAKE += ' STAGING_INCDIR=${STAGING_INCDIR} STAGING_LIBDIR=${STAGING_LIBDIR}'

do_install_prepend() {
        oe_runmake -C ${STAGING_KERNEL_DIR} mrproper
        oe_runmake -C ${STAGING_KERNEL_DIR} scripts
}
© www.soinside.com 2019 - 2024. All rights reserved.