Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
653 views
in Technique[技术] by (71.8m points)

yocto - bitbake fail, cannot find .cpp file

This is my .bb file, I already git clone the repo at /home/chtan/rcu-service

SUMMARY = "RCU Service"
DESCRIPTION = "Recipe to install RCU Service into RCU image"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

inherit systemd
SYSTEMD_AUTO_ENABLE = "enable"
SYSTEMD_SERVICE_${PN} = "rcu-service.service"

inherit externalsrc
EXTERNALSRC = "/home/chtan/rcu-service"
EXTERNALSRC_BUILD = "${EXTERNALSRC}"


FILES_${PN} += "${systemd_unitdir}/system/rcu-service.service"
S = "${WORKDIR}"

TARGET_CC_ARCH += "${LDFLAGS}"

do_compile() {
         ${CXX} rcu-service.cpp -o rcu-service
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 rcu-service ${D}${bindir}
         install -d ${D}/${systemd_unitdir}/system
         install -m 0644 ${WORKDIR}/git/rcu-service.service ${D}/${systemd_unitdir}/system
}
enter code here

However, it fail during bitbake, please refer to syntax at below

2021-02-04T16:26:47.6181432Z aarch64-tdx-linux-g++: error: rcu-service.cpp: No such file or directory

2021-02-04T16:26:55.9000799Z Summary: 1 task failed:

2021-02-04T16:26:55.9001769Z /__w/1137/s/build/../layers/meta-smartracks/recipes-core/rcu-service/rcu-service_1.0.bb:do_compile

My files(rcu-service.cpp , rcu-service.service) are located at /home/chtan/rcu-service What Syntax should I add in my .bb file in order to let compiler reaches my file ?

question from:https://stackoverflow.com/questions/66049872/bitbake-fail-cannot-find-cpp-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You must change your do_compile build step as this for this to work.

do_compile() {
          ${CXX} ${S}/rcu-service.cpp -o rcu-service
}

In do_install you should change ${WORKDIR}/git/rcu-service.service to ${S}/git/rcu-service.service

Extract from the yocto project manual
By default, the OpenEmbedded build system uses the S and B variables to locate unpacked recipe source code and to build it, respectively. When your recipe inherits the externalsrc class, you use the EXTERNALSRC and EXTERNALSRC_BUILD variables to ultimately define S and B.

So in your case S and B will have the following values

S="/home/chtan/rcu-service"
B="/home/chtan/rcu-service"

Note you dont need to set ${WORKDIR}/rcu-service since the command dir is already ${WORKDIR} you could check this by adding the following line

bbwarn $(pwd) 

in your do_compile task.

You should also remove the following line since it gets overwriten by the externalsrc.bbclass

S = "${WORKDIR}"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...