Topics

yocto compile simple c++


Sergey Ivanov
 

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
    └── ice_helloworld
        ├── COPYING.MIT
        ├── 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"
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[md5sum] = "bc9dc64a44f9685d0310b94400a4631c"
SRC_URI[sha256sum] = "789e60072ea96371a35d5653d664b4c4b91e80ce2ea6d523d6caedab06a07a2a"
LIC_FILES_CHKSUM = "${SITE}COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

do_compile() {
    ${CXX} ${PN}.cpp -o ${PN}
}

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

what could be wrong here?
--
Kind regards,
Sergey Ivanov


Sol
 

As far as I know, you have to given a checksum for the license:
LIC_FILES_CHKSUM = "file://gpl-2.0.txt;md5=ab04ac0f249af12befccb94447c08b77" or something like that.

Hope this helps.

On Sat, 8 Aug 2020 at 19:13, Sergey Ivanov <icegood1980@...> 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
    └── ice_helloworld
        ├── COPYING.MIT
        ├── 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"
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[md5sum] = "bc9dc64a44f9685d0310b94400a4631c"
SRC_URI[sha256sum] = "789e60072ea96371a35d5653d664b4c4b91e80ce2ea6d523d6caedab06a07a2a"
LIC_FILES_CHKSUM = "${SITE}COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

do_compile() {
    ${CXX} ${PN}.cpp -o ${PN}
}

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

what could be wrong here?
--
Kind regards,
Sergey Ivanov


codusnocturnus
 

Bitbake is unable to find the license file because it's looking in the wrong place.  If you look at the contents of /media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/ice_helloworld-helloworld/ , you will probably find it to be empty, and you will find COPYING.MIT in the directory above it.

The reason is that ${S} (see https://www.yoctoproject.org/docs/3.1.2/ref-manual/ref-manual.html#var-Sdefaults to a location where a tarball would be unpacked, but your recipe isn't using a tarball.

Add the following to your recipe:
S = "${WORKDIR}"

Thanks,


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Saturday, August 8, 2020 2:12 AM, Sergey Ivanov <icegood1980@...> 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
    └── ice_helloworld
        ├── COPYING.MIT
        ├── 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"
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[md5sum] = "bc9dc64a44f9685d0310b94400a4631c"
SRC_URI[sha256sum] = "789e60072ea96371a35d5653d664b4c4b91e80ce2ea6d523d6caedab06a07a2a"
LIC_FILES_CHKSUM = "${SITE}COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

do_compile() {
    ${CXX} ${PN}.cpp -o ${PN}
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${PN} ${D}${bindir}
}
what could be wrong here?
--
Kind regards,
Sergey Ivanov


codusnocturnus
 

I see.  If you're going to provide the license with the recipe or code, then it needs to be in a subdirectory under the recipe file.  So the only one in your tree that matters for this is .../recipes-ice/files/COPYING.MIT.

Then you will need to explicitly list it in SRC_URI:
SRC_URI = "${SITE}${PN}.cpp \
                     ${SITE}COPYING.MIT"

An alternative, for common licenses, is to use a link like this:
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

You will still need this for your recipe to find the license or your source file:
S = "${WORKDIR}"

Thanks,


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Sunday, August 9, 2020 2:48 AM, Sergey Ivanov <icegood1980@...> wrote:

Hi. Unfortunately i tried it and it is not my case. To be precise, i don't see COPYING.MIT at any sibfolder of 
/media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld
at all...

сб, 8 авг. 2020 г. в 14:31, codusnocturnus via lists.yoctoproject.org <codusnocturnus=protonmail.com@...>:
Bitbake is unable to find the license file because it's looking in the wrong place.  If you look at the contents of /media/ice/slow_ext4/yocto_poky/build/tmp/work/armv7vet2hf-neon-poky-linux-gnueabi/ice_helloworld/helloworld-0.1/ice_helloworld-helloworld/ , you will probably find it to be empty, and you will find COPYING.MIT in the directory above it.

The reason is that ${S} (see https://www.yoctoproject.org/docs/3.1.2/ref-manual/ref-manual.html#var-Sdefaults to a location where a tarball would be unpacked, but your recipe isn't using a tarball.

Add the following to your recipe:
S = "${WORKDIR}"

Thanks,


Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Saturday, August 8, 2020 2:12 AM, Sergey Ivanov <icegood1980@...> 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
    └── ice_helloworld
        ├── COPYING.MIT
        ├── 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"
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[md5sum] = "bc9dc64a44f9685d0310b94400a4631c"
SRC_URI[sha256sum] = "789e60072ea96371a35d5653d664b4c4b91e80ce2ea6d523d6caedab06a07a2a"
LIC_FILES_CHKSUM = "${SITE}COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

do_compile() {
    ${CXX} ${PN}.cpp -o ${PN}
}

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${PN} ${D}${bindir}
}
what could be wrong here?
--
Kind regards,
Sergey Ivanov




--
Kind regards,
Sergey Ivanov


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