On 30 September 2015 at 04:28, Simon Castillo <[email protected]> wrote:
> Hello to all, > > I have searching for a way to include a library-only in yocto. I found > couple links with suggestions but I was unsuccessful in the to package it > in the final image. Reading the yocto documentation, I see a paragraph > mentioning about static libraries but there is no examples. > > I will try to be precise with the hopes to find help to tackle this issue. > > NOTE: Couple steps like creating a LICENSE file, crate the layer and > update the local.conf file are omitted > > =============================== > The problem: > - Creating a library that it is desired to be part of the final image (for > example core-image-base, core-image-sato). No application, only a library > ============================== > Test scenario: > > Let's say that we desire to create a simple library called simple lib. > > The source code is as follows (taken from this link [ > http://www.adp-gmbh.ch/cpp/gcc/create_lib.html], copied here just for > convenience) > > calc_mean.c > //#include <stdio.h> > > double mean(double a, double b) { > return (a+b) / 2; > } > > calc_mean.h > double mean(double, double); > > Now we want to create a recipe that can compile, create a library and can > be included in the final image (let's assume core-image-base) > > ============================ > RECIPE > Recipe name => simplelib_0.1.0.bb > =========================== > > DESCRIPTION = "Simple Library on yocto" > LICENSE = "GPLv2" > LIC_FILES_CHKSUM = "file://LICENSE;md5=c0b0999e102092552f1dfe93fb9b0068" > > PR = "r0" > SRC_URI = "file://simplelib.zip" > > S = "${WORKDIR}/simplelib/" > > do_compile(){ > ${CC} -c calc_mean.c -o calc_mean.o > ${AR} rcs libmean.a calc_mean.o > } > > do_install{ > install -d ${D}${libdir} > install -m 0644 libmean.a ${D}${libdir} > } > ===================== > Test results for RECIPE: > > $ bitbake simplelib > > RUNS without any problem. The files generated are shown below > > ├── configure.sstate > ├── deploy-ipks > │ └── cortexa8hf-vfp-neon > │ ├── simplelib-dbg_0.1.0-r0_cortexa8hf-vfp-neon.ipk > │ ├── simplelib-dev_0.1.0-r0_cortexa8hf-vfp-neon.ipk > │ └── simplelib-staticdev_0.1.0-r0_cortexa8hf-vfp-neon.ipk > ├── image > │ └── usr > │ └── lib > │ └── libmean.a > ├── license-destdir > │ └── simplelib > │ ├── generic_GPLv2 > │ └── LICENSE > ├── package > │ └── usr > │ └── lib > │ └── libmean.a > ├── packages-split > │ ├── simplelib > │ ├── simplelib-dbg > │ ├── simplelib-dev > │ ├── simplelib-doc > │ ├── simplelib-locale > │ └── simplelib-staticdev > │ └── usr > │ └── lib > │ └── libmean.a > ├── pkgdata > │ ├── runtime > │ │ ├── simplelib > │ │ ├── simplelib-dbg > │ │ ├── simplelib-dbg.packaged > │ │ ├── simplelib-dev > │ │ ├── simplelib-dev.packaged > │ │ ├── simplelib-doc > │ │ ├── simplelib-locale > │ │ ├── simplelib-staticdev > │ │ └── simplelib-staticdev.packaged > │ ├── runtime-reverse > │ │ ├── simplelib-dbg -> ../runtime/simplelib-dbg > │ │ ├── simplelib-dev -> ../runtime/simplelib-dev > │ │ └── simplelib-staticdev -> ../runtime/simplelib-staticdev > │ ├── runtime-rprovides > │ ├── shlibs2 > │ └── simplelib > ├── pseudo > │ ├── files.db > │ ├── logs.db > │ ├── pseudo.lock > │ ├── pseudo.log > │ ├── pseudo.pid > │ └── pseudo.socket > ├── simplelib > │ ├── calc_mean.c > │ ├── calc_mean.h > │ ├── calc_mean.o > │ ├── libmean.a > │ └── LICENSE > ├── sysroot-destdir > │ ├── sysroot-providers > │ │ └── simplelib > │ └── usr > │ └── lib > │ └── libmean.a > > =============== > Test result to include library in the image > > $ bitbake core-image-base > > FAILS, > > * opkg_install_cmd: Cannot install package simplelib. > > ERROR: Function failed: do_rootfs > > ============== > TRY ONE, > > Change the recipe and add RDEPENDS_${PN}-dev = "" as suggested by > https://lists.yoctoproject.org/pipermail/yocto/2014-September/021676.html > > FAILS, same error > * opkg_install_cmd: Cannot install package simplelib. > This really should help: your problem is probably that the actual simplelib package is not created (because there are no files to put into it), but the -dev package still RDEPENDS on it by default. The log file might give you more details though. "grep RDEPENDS pkgdata/runtime/*" in work directory should show what the RDEPENDS are. How are you adding the library to your image? You should be adding the package "simplelib-staticdev" to it (assuming you really only want a static .a). > ============= > TRY TWO > > Modify recipe adding below lines (based on > http://stackoverflow.com/questions/28792597/how-to-add-a-new-library-using-yocto > ) > > PACKAGES = "${PN} ${PN}-dev ${PN}-dbg ${PN}-staticdev" > > FILES_${PN} = " \ > ${libdir}/simplelib/ \ > " FAILS, same error > * opkg_install_cmd: Cannot install package simplelib. > =============== > This SO question was fixing a slightly different problem: adding any files to FILES_${PN} would solve your problem as well (because the ${PN} package would then exist) but the files you refer to do not exist so nothing is added... I am sure that it is something simple and common that many have done in the > past but unfortunately I can not find an example on how to do it. Hope > somebody could provide a hint on how to fix this problem. > Hope that helps, Jussi
-- _______________________________________________ yocto mailing list [email protected] https://lists.yoctoproject.org/listinfo/yocto
