1
votes

I am a building a custom image using Yocto (THUD) for an imx6 processor. With the image, I created a recipe for a QT application and a recipe for a c++ library that uses cmake to build.

I am looking into building the SDK for that image. I want the SDK to allow cross-compilation, but also to compile the QT application so it can run on the host machine (SDKMACHINE). The cross-compilation part works like a charm. It is the part about building the QT application to run on the host machine that I am having trouble with.

First, here is the recipe for the library:

SRC_URI = "file://LibName"

inherit cmake

S = "${WORKDIR}"

FILES_${PN} += "${includedir}/*.h ${includedir}/"

BBCLASSEXTEND = "native nativesdk"

do_configure() {
    cmake  ../LibName/src
}

do_install() {
    install -d ${D}${libdir}
    install -m 0755 ${S}/build/libLibName.so ${D}${libdir}/libLibName.so.0
    ln -s libLibName.so.0 ${D}${libdir}/libLibName.so
    install -m 0755 ${S}/build/libLibName.a ${D}${libdir}

    install -d ${D}${includedir}/LibName/
    cp -r ${S}/LibName/includes ${D}${includedir}/LibName/
    install -d ${D}${includedir}/LibName/src
    rsync -a --include='*.h' --include='*/' --exclude='*' ${S}/LibName/src/ ${D}${includedir}/LibName/src
}

And in my image recipe file, I added:

TOOLCHAIN_HOST_TASK += "nativesdk-lib-name"

I then build the SDK using:

bitbake -c populate_sdk custom-iamge-recipe

My problem is the resulting SDK does not have the include files I would expect in the native sysroot. I was expecting my native sysroot (/opt/fslc-x11/2.6.2/sysroots/x86_64-fslcsdk-linux/usr/include) would contain the c++ library includes files just like the target sysroot (/opt/fslc-x11/2.6.2/sysroots/armv7at2hf-neon-fslc-linux-gnueabi).

Another thing I don't understand is that the native sysroot contains the library (libLibName.so.0), but not the symbolic link (libLibName.so). I was expecting the symbolic link to appear just like it does in the target sysroot.

Here is what I have right now:

/opt/fslc-x11/2.6.2/sysroots
├── armv7at2hf-neon-fslc-linux-gnueabi/usr
│   ├── include
│   │   └── LibName
│   │       └── include files
│   └── lib
│       ├── libLibName.so.0
│       └── libLibName.so 
└── x86_64-fslcsdk-linux/usr
    └── lib
        └── libLibName.so.0

Here is what I would like:

/opt/fslc-x11/2.6.2/sysroots
├── armv7at2hf-neon-fslc-linux-gnueabi/usr
│   ├── include
│   │   └── LibName
│   │       └── include files
│   └── lib
│       ├── libLibName.so.0
│       └── libLibName.so 
└── x86_64-fslcsdk-linux/usr
    ├── include
    │   └── LibName
    │       └── include files
    └── lib
        ├── libLibName.so.0
        └── libLibName.so 

Thanks in advance for the help, it is greatly appreciated!

1
Offhand FILES_${PN} looks wrong because you install to "${includedir}/LibName/". not "${includedir}/".fdk1342
headers will be in <libname>-dev as -dev is created before <package>. So probably need to set PACKAGES variable directly or include -dev as well.Nayfe
@Nayfe , your comment worked. I added the the dev package, TOOLCHAIN_HOST_TASK += "nativesdk-lib-name nativesdk-lib-name-dev". It added the include files and the symbolic link. Thank you so much! Would you like to write your comment as an answer so I can accept it?Olivier

1 Answers

2
votes

PACKAGES variable is defined here as:

PACKAGES = "${PN}-src ${PN}-dbg ${PN}-staticdev ${PN}-dev ${PN}-doc ${PN}-locale ${PACKAGE_BEFORE_PN} ${PN}"

So when Yocto packages files from recipe, it includes them in PACKAGES order, in this case, headers files are included in ${PN}-dev before it can be included in ${PN}:

FILES_${PN}-dev = "${includedir} ..."

To add headers to your SDK, you can add -dev package:

TOOLCHAIN_HOST_TASK += "nativesdk-lib-name nativesdk-lib-name-dev"

Note you could also redefine PACKAGES variable this way :

PACKAGES = "${PN}"

to get your line to work: FILES_${PN} += "${includedir}/*.h ${includedir}/"