Re: yocto compile simple c++


Quentin Schulz
 

Hi Sergey,

On Sat, Aug 08, 2020 at 12:12:40PM +0300, Sergey Ivanov wrote:
Hi there.
I'm newbie ib yocto and (of course) nothing works for me from scratch.
For testing purposes, i work with yocto 3.1 based on
5d47cdf448b6cff5bb7cc5b0ba0426b8235ec478 rev aka dunfell-23.0.0
MACHINE ?= "qemuarm" and DISTRO ?= "poky" (btw i tried poky-tony as well
but machine didn't start properly under qemu)

I created my new layer with next structure:
.
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-ice
├── COPYING.MIT
No need.

└── ice_helloworld
├── COPYING.MIT
No need.

├── files
│ ├── COPYING.MIT
│ └── ice_helloworld.cpp
└── ice_helloworld_0.1.bb

(i copied COPYING.MIT to )every single place because of error below) and i
obtained:

NOTE: Executing Tasks
WARNING: ice_helloworld-helloworld-0.1 do_populate_lic: Could not copy
license file
/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/ice_helloworld-helloworld/COPYING.MIT
to
/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/license-destdir/ice_helloworld/COPYING.MIT:
[Errno 2] No such file or directory:
'/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/ice_helloworld-helloworld/COPYING.MIT'
ERROR: ice_helloworld-helloworld-0.1 do_populate_lic: QA Issue:
ice_helloworld: LIC_FILES_CHKSUM points to an invalid file:
/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/ice_helloworld-helloworld/COPYING.MIT
[license-checksum]
ERROR: ice_helloworld-helloworld-0.1 do_populate_lic: Fatal QA errors
found, failing task.
ERROR: Logfile of failure stored in:
/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/temp/log.do_populate_lic.133477
ERROR: Task
(/media/ice/slow_ext4/yocto_poky/meta-ice_layer/recipes-ice/ice_helloworld/ice_helloworld_0.1.bb:do_populate_lic)
failed with exit code '1'
NOTE: Tasks Summary: Attempted 216 tasks of which 214 didn't need to be
rerun and 1 failed.




my bb file is:

SUMMARY = "Recipe to build the 'helloworld' in cpp"
SECTION = "ice"
LICENSE="MIT"
#LICENSE_PATH += "${LAYERDIR}"

PN = "ice_helloworld"
No need, default is the name of the recipe file.

PV = "0.1"
No need, default is the version in the recipe file (if there's one).

meta-ice_layer/recipes-ice/ice_helloworld/ice_helloworld_0.1.bb will
produce:
PN = "ice_helloworld"
PV = "0.1"

SITE = "file://"
PACKAGE_VERSION_MAJOR = "${@bb.data.getVar('PV',d,1).split('.')[0]}"
PACKAGE_VERSION_MINOR = "${@bb.data.getVar('PV',d,1).split('.')[1]}"

SRC_URI = "${SITE}${PN}.cpp"
SRC_URI = "${SITE}/${PN}.cpp"

SRC_URI[md5sum] = "bc9dc64a44f9685d0310b94400a4631c"
SRC_URI[sha256sum] =
"789e60072ea96371a35d5653d664b4c4b91e80ce2ea6d523d6caedab06a07a2a"
LIC_FILES_CHKSUM = "${SITE}COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
LIC_FILES_CHKSUM = "${SITE}/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

do_compile() {
${CXX} ${PN}.cpp -o ${PN}
}
Create a makefile/cmake instead, the logic of compiling your SW shouldn't be
in a build system.

do_install() {
install -d ${D}${bindir}
install -m 0755 ${PN} ${D}${bindir}
}
Same, create an install target in your makefile. If you do this well,
you don't even need your do_compile and do_install, it'll be
"automagical".

what could be wrong here?
--
1. Missing / in your paths.

2. Also, **never** put uppercase letter or underscores in the name of
a recipe. So your recipe should be:
meta-ice_layer/recipes-ice/ice-helloworld/ice-helloworld_0.1.bb

The underscore is used in multiple places internally to separate
things so using an underscore is breaking some things in weird ways.

Fix 1 and 2 at least, create a makefile for added best practices.

Kind regards,
Quentin

Join yocto@lists.yoctoproject.org to automatically receive all group messages.