简体   繁体   中英

How to add header file to /usr/include in Yocto

I am working with Linux built with Yocto. I would like to add to the image my app to /bin and some header file to /usr/include . I have no problem with adding the app to /bin , but I am not able to add the header file to my rootfs. The .h file is added to a proper package, but it is not copied to rootfs.

Here is my recipe:

bindir = "${localdir}/bin"
incldir = "${localdir}/usr/include"

FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"
SRC_URI = "file://My_app_dir/* \
          \     
          "
S = "${WORKDIR}"

FILES_${PN} += "${incldir}/*"

do_compile() {

    cd My_app_dir/src
    make       
}

do_install() {
    install -d ${D}${bindir}
    cp "${S}/My_app_dir/src/my_app" "${D}${bindir}/my_app"

    install -d ${D}${incldir}
    cp "${S}/My_app_dir/some_lib.h" "${D}${incldir}/some_lib.h"
}

After building the image, the include file exists in /build/tmp/work/<machine>/<my_app>/image/usr/include .

Do you have any idea why I cannot add .h file to /usr/include in rootfs? Thank you in advance for any help.

The header files (among other files like pkgconfig and shared library symlinks) are not added to the main package (say foo ), but to the development package (eg foo-dev ). This is called package split and you can learn more in the Package Splitting of the official documentation . The development packages (and BTW also the debug foo-dbg ) are not installed by default.

But please be aware that adding the development package may pull other dependencies (because of various runtime dependencies) and files (there are other files in the development package).

Please note that your line FILES_${PN} += "${incldir}/*" has no effect, as the files in $includedir (ie FILES_${PN}-dev ) are split before the FILES_${PN} are processed. The order is defined in the variable PACKAGES (check the official documentation) .

BTW, there are minor things in the recipe which you can update (unrelated to your question though):

  • You can use location of standard system paths in the respective variables bindir , includedir etc.
  • install is preferred over the cp in do_install .
  • The line FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" is needed only in bbappends . The files directory inside the recipe's directory is in the standard search path of files (among other paths like ${PN} etc.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM