Search code examples
shared-librariesyoctobitbakeyocto-recipe

Yocto add Shared Library


I am trying to compile this GitHub project I found and add the resulting shared library to my SDK.

The project uses CMake. My recipe can download, and build this project. The resulting binary files work as expected, the given .so files contain what I need. When trying to add the .so files to my image I get the errors

ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA Issue: -dev package dbcppp-dev contains non-symlink .so '/usr/lib/libdbcppp.so'
-dev package dbcppp-dev contains non-symlink .so '/usr/lib/libxmlmm.so' [dev-elf]
ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA Issue: dbcppp rdepends on dbcppp-dev [dev-deps]
ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: Logfile of failure stored in: /home/michael/Documents/MAIN_Application/build-fb/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/dbcppp/1.0+gitrAUTOINC+917c925638-r0/temp/log.do_package_qa.10943
ERROR: Task (/home/michael/Documents/MAIN_Application/MAIN_layers/meta-MAINapplication/recipes-core/dbcppp/dbcppp_0.0.bb:do_package_qa) failed with exit code '1'

My recipe is as follows:

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
        
PV = "1.0+gitr${SRCPV}"
SRCREV = "${AUTOREV}"

S = "${WORKDIR}/git"

inherit pkgconfig cmake

INSANE_SKIP:${PN} = "ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${B}/bin/dbcppp ${D}${bindir}
    
     install -d ${D}${libdir}
     install -m 0755 ${B}/src/libdbcppp/libdbcppp.so ${D}${libdir}
     install -m 0755 ${B}/libxmlmm.so ${D}${libdir}
     install -m 0755 ${B}/third-party/libxml2/libxml2.so.2.9.10 ${D}${libdir}          
}

FILES_${PN} += "${libdir}/*"
FILES_${PN}-dev = "${libdir}/* ${includedir}"

I have been searching for a while but I cannot find a solution. What do I need to do for this to work?

Edit 1: I updated my bb file to the following. This works but it does not place the necessary header files into my SDK.

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
        
PV = "1.0+gitr${SRCPV}"
SRCREV = "${AUTOREV}"

S = "${WORKDIR}/git"

inherit cmake

INSANE_SKIP:${PN} = "ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${B}/bin/dbcppp ${D}${bindir}
    
     install -d ${D}${libdir}
     install -m 0755 ${B}/src/libdbcppp/libdbcppp.so ${D}${libdir}
     install -m 0755 ${B}/libxmlmm.so ${D}${libdir}
     install -m 0755 ${B}/third-party/libxml2/libxml2.so ${D}${libdir}          
}

FILES_${PN} += "${libdir}/*.so"
FILES_${PN}-dev = "${includedir}"

Solution

  • The dbcppp Cmake file already has an install target that installs everything automatically, so you do not need do_install.

    Try the following recipe:

    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    
    SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
    PV = "1.0+gitr${SRCPV}"
    SRCREV = "${AUTOREV}"
    
    S = "${WORKDIR}/git"
    
    inherit cmake
    
    FILES_${PN} += "/usr/lib/xml2Conf.sh /usr/lib/lib*.so.*"
    
    SOLIBS = ".so"
    FILES_SOLIBSDEV = ""
    INSANE_SKIP_${PN} += "dev-so"
    

    The non-versioned shared libraries .so topic is difficult in Yocto, that's why skipping the QA shared library issue is the way to go here if you have no control on the source project's files/libraries.

    The above recipe splits into multiple packages:

    • dbcppp (If you want just the dbcppp binary (.so files are shipped for the binary to run)
    • dbcppp-dev (If you want the header files and the shared libraries)
    • dbcppp-doc (If you want the man and html pages)