Search code examples
opencvyoctodlibrecipe

yocto recipe for an application that uses dlib and opencv


I made a yocto recipe for dlib and also I added opencv package in local.conf. Now I want to make a recipe for an application that uses dlib and opencv libraries. I tried the following recipe, but when I try to build it with bitbake application, it throws me some errors. dlib recipe:

SUMMARY = "A toolkit for making real world machine learning and data analysis applications"
HOMEPAGE = "https://github.com/davisking/dlib"

LICENSE = "Boost-Software"
LIC_FILES_CHKSUM = "file://dlib/LICENSE.txt;md5=2c7a3fa82e66676005cd4ee2608fd7d2 \
                    file://dlib/external/pybind11/LICENSE;md5=beb87117af69fd10fbf9fb14c22a2e62 \
                    file://dlib/external/libpng/LICENSE;md5=243135ddedf702158f9170807cbcfb66 \
                    file://docs/docs/license.xml;md5=2e6ff4080dcb217d4d300b90e9aabb5b \
                    file://examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt;md5=57eee82829ed297e23d84de5f905afee \
                    file://examples/video_frames/license.txt;md5=127ee508b60a6be9dea8af3b441993dc \
                    file://python_examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt;md5=064f53ab40ea2b6a4bba1324149e4fde"

SRC_URI = "git://github.com/davisking/dlib.git;protocol=https"

PV = "1.0+git${SRCPV}"
SRCREV = "3b794540baeabbcd033b544230401967106d5483"

S = "${WORKDIR}/git"

do_compile() {
        cd ${S}
        cd dlib
        mkdir build
        cd build
        cmake ..
        sudo make install
}

FILES_${PN} += "/${base_prefix}"
inherit cmake

application recipe:

DESCRIPTION = "Simple application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://application.cpp;md5=df22013877ba7d830e9993ae1d77d724"

SRC_URI = "file://application.cpp"

S = "${WORKDIR}"

do_compile() {
        ${CXX}  -std=c++11 -O3 -L${libdir}/libdlib.a -I${includedir}/dlib/ -lpthread -lX11  application.cpp ${LDFLAGS} `pkg-config --cflags --libs opencv` -o application
}

do_install() {
        install -d ${D}${bindir}
        install -m 0755 application ${D}${bindir}
}

some errors when I try bitbake application:

| application.cpp:(.text._ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm[_ZN4dlib30entropy_decoder_model_kernel_5ILm257ENS_24entropy_decoder_kernel_2ELm200000ELm4EE6decodeERm]+0x1a8): undefined reference to `dlib::entropy_decoder_kernel_2::get_target(unsigned int)'
| application.cpp:(.text._ZN4dlib11pinv_helperINS_9matrix_opINS_8op_transINS_6matrixIdLl3ELl0ENS_33memory_manager_stateless_kernel_1IcEENS_16row_major_layoutEEEEEEEEEKNS3_INT_4typeEXsrSA_2NCEXsrSA_2NRENSA_16mem_manager_typeES6_EERKNS_10matrix_expISA_EEd[_ZN4dlib11pinv_helperINS_9matrix_opINS_8op_transINS_6matrixIdLl3ELl0ENS_33memory_manager_stateless_kernel_1IcEENS_16row_major_layoutEEEEEEEEEKNS3_INT_4typeEXsrSA_2NCEXsrSA_2NRENSA_16mem_manager_typeES6_EERKNS_10matrix_expISA_EEd]+0x4fc): undefined reference to `cblas_dgemm'
| application.cpp:(.text._ZN4dlib28get_serialized_frontal_facesB5cxx11Ev[_ZN4dlib28get_serialized_frontal_facesB5cxx11Ev]+0x8e9c): undefined reference to `dlib::base64::~base64()'

What can I do in order to slove this problem?


Solution

  • Change the dlib recipe to

    SUMMARY = "A toolkit for making real world machine learning and data analysis applications"
    HOMEPAGE = "https://github.com/davisking/dlib"
    
    LICENSE = "Boost-Software"
    LIC_FILES_CHKSUM = "file://dlib/LICENSE.txt;md5=2c7a3fa82e66676005cd4ee2608fd7d2 \
                        file://dlib/external/pybind11/LICENSE;md5=beb87117af69fd10fbf9fb14c22a2e62 \
                        file://dlib/external/libpng/LICENSE;md5=243135ddedf702158f9170807cbcfb66 \
                        file://docs/docs/license.xml;md5=2e6ff4080dcb217d4d300b90e9aabb5b \
                        file://examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt;md5=57eee82829ed297e23d84de5f905afee \
                        file://examples/video_frames/license.txt;md5=127ee508b60a6be9dea8af3b441993dc \
                        file://python_examples/LICENSE_FOR_EXAMPLE_PROGRAMS.txt;md5=064f53ab40ea2b6a4bba1324149e4fde"
    
    SRC_URI = "git://github.com/davisking/dlib.git;protocol=https"
    
    PV = "1.0+git${SRCPV}"
    SRCREV = "3b794540baeabbcd033b544230401967106d5483"
    
    S = "${WORKDIR}/git"
    
    inherit cmake
    
    EXTRA_OECMAKE += "-DDLIB_NO_GUI_SUPPORT=ON -DBUILD_SHARED_LIBS=ON"
    

    Then in your application recipe

    DESCRIPTION = "Simple application"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://application.cpp;md5=df22013877ba7d830e9993ae1d77d724"
    
    inherit pkgconfig 
    DEPENDS += "dlib opencv"
    
    SRC_URI = "file://application.cpp"
    
    S = "${WORKDIR}"
    
    do_compile() {
            ${CXX} ${CXXFLAGS} -std=c++11 -O3 -I${STAGING_INCDIR}/dlib -pthread application.cpp -o application ${LDFLAGS} `pkg-config --cflags --libs opencv` -lX11 -ldlib
    }
    
    do_install() {
            install -D -m 0755 application ${D}${bindir}/application
    }