Issue
As I am new to yocto, I've been trying to make a recipe from simple C program which uses makefile to generate the binary. After creating the recipe I am getting the following error
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'
Here is my recipe
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}
}
And here is my makefile
SRCS = $(wildcard *.c)
CC = gcc
OBJ_NAME = hello_shell
all : ${SRCS}
$(CC) $(SRCS) -o $(OBJ_NAME)
clean :
rm $(OBJ_NAME)
I am facing build errors. I am buiding it with the meta-raspberrypi My complete build
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)$
What mistake am I doing ?
Solution
Error occurred because you have CC = gcc
in makefile which points to compiler in host
. This overrides CROSS_COMPILER
set by yocto. so the binary you built hello_shell
is for host (ELF 64-bit LSB executable, x86-64), which throws error while using aarch64-poky-linux-objcopy
Try removing CC = gcc
from makefile
Answered By - Praveen Muthusamy Answer Checked By - Mary Flores (WPSolving Volunteer)