Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Yocto, how to include header files from another recipes

Tags:

yocto

My program depends on the poco recipes, which provides both the header files and shared libraries. However, I cannot make use of the header files from poco in my recipe, which leads to the error Poco/Delegate.h: No such file for directory.

How do I make the header available at build time for my software package?

Here is an example recipe:

SUMMARY = ""
DESCRIPTION = ""
AUTHOR = ""
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
HOMEPAGE = ""
BUGTRACKER = ""

S = "${WORKDIR}"

SRC_URI = " file://foo.cpp \
            file://CMakeLists.txt \
"

inherit pkgconfig cmake

DEPENDS_foo = "poco"
RDEPENDS_foo = "poco"

do_install() {
    install -d ${D}/${bindir}
    install -m 755 ${S}/foo ${D}/${bindir}
}

FILES_${PN} = "${bindir}/foo"
like image 215
Amumu Avatar asked Apr 26 '18 05:04

Amumu


People also ask

How do I add BB files to yocto?

Adding new recipes to the build system One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.

What is Workdir in yocto?

WORKDIR. The pathname of the work directory in which the OpenEmbedded build system builds a recipe. This directory is located within the TMPDIR directory structure and is specific to the recipe being built and the system for which it is being built.


1 Answers

We can use provider and user to illustrate this case, the package (recipe) provides a header file to be used by another package (recipe) is the provider, the package (recipe) use a header file from another package (recipe) is the user.

First we change the provider's recipe (myprovider.bb) to export the header file -- myapi.h,

...
do_install() {

    install -d ${D}/${bindir}
    install -m 755 ${B}/hello_provider ${D}/${bindir}

    install -d ${D}${libdir}/lib_myprovider/
    install -m 0755 ${WORKDIR}/myapi.h ${STAGING_DIR_TARGET}${libdir}/lib_myprovider/
}
...

Secondly we change the user's recipe (myuser.bb) to refer the header file -- myapi.h

...
do_compile () {    

    ${CC} ${WORKDIR}/main.c -o hello_user ${CFLAGS} ${LDFLAGS} -I${STAGING_DIR_TARGET}/${libdir}/lib_myprovider/ 
}

# file dependency declaration
FILES_${PN} = "${libdir}/lib_myprovider"

# package dependency declaration
DEPENDS += "myprovider"
...

At last, rebuild myprovider.bb and myuser.bb recipes, it should work.

like image 158
Zephyr Avatar answered Oct 06 '22 01:10

Zephyr