Post Go back to editing

mcapi yocto recipe is broken

I've been attempting to use MCAPI to converse with the SHARC+ cores on an SC589.

The recipe for libmcapi.so doesn't publish header files so you can't actually compile anything with it.

But after a trivial patch, I still can't get a simple program to link using a yocto recipe.  Either my linking with `-lmcapi` isn't right, or there's something else required because I only get "undefined reference to `mcapi_initialize'"

Has anyone ever actually used a yocto built arm mcapi application to talk to a SHARC+ core?

diff --git a/meta-adi-adsp-sc5xx/recipes-icc/libmcapi/libmcapi.bb b/meta-adi-adsp-sc5xx/recipes-icc/libmcapi/libmcapi.bb
index db41169..a503400 100644
--- a/meta-adi-adsp-sc5xx/recipes-icc/libmcapi/libmcapi.bb
+++ b/meta-adi-adsp-sc5xx/recipes-icc/libmcapi/libmcapi.bb
@@ -29,9 +29,14 @@ do_compile_prepend(){
 
 do_install(){
        install -d ${D}/usr/bin
-       install -d ${D}/usr/lib 
+       install -d ${D}/usr/lib
+       install -d ${D}/usr/include
        install -m 755 ${S}/tests/.libs/* ${D}/usr/bin/
        install -m 755 ${S}/.libs/libmcapi.so.0.0.0 ${D}/usr/lib/
-       ln -s libmcapi.so.0.0.0 ${D}/usr/lib/libmcapi.so.0 
-       ln -s libmcapi.so.0.0.0 ${D}/usr/lib/libmcapi.so 
-}
\ No newline at end of file
+       ln -s libmcapi.so.0.0.0 ${D}/usr/lib/libmcapi.so.0
+       ln -s libmcapi.so.0.0.0 ${D}/usr/lib/libmcapi.so
+       install ${S}/include/*.h ${D}/usr/include
+}
+
+FILES_${PN} += "/usr/lib/* /usr/bin/*"
+FILES_${PN}-dev += "/usr/include"



spelling
[edited by: rireland at 7:03 PM (GMT -5) on 25 Jan 2022]
Parents
  • Hi rireland,

    Linking -lmcapi should be able to build your application without the undefined reference error.
    Can you please try passing the -L/path/to/lib/directory.

    If you still run into the same issue, pls share you custom recipe to reproduce the issue from my side.

    Thanks
    Vignesh R

  • The command line output by a verbose bitbake compile contains the proper path to the sysroot/usr/lib with the -L option for the recipe and the mcapi.so libraries are there.

    Here's compile commandline with the full paths redacted:
    (unfortunately it looks like the `code` macro is truncating the lines)

    |  <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot-default/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/collect2 -plugin <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot-default/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/liblto_plugin.so -plugin-opt=<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot-default/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccYiRBSC.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot --build-id --eh-frame-hdr --hash-style=sysv -dynamic-linker /lib/ld-linux-armhf.so.3 -X -m armelf_linux_eabi -pie -o mcapi-demo <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/Scrt1.o <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/crti.o <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/arm-poky-linux-gnueabi/8.2.0/crtbeginS.o -L<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot-default/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0 -L<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot-default/usr/bin/arm-poky-linux-gnueabi/../../lib/arm-poky-linux-gnueabi/gcc -L<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/lib -L<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/arm-poky-linux-gnueabi/8.2.0 -L<redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib -O1 --hash-style=gnu --as-needed -z relro -z now -lmcapi /tmp/cc7c1WLA.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/arm-poky-linux-gnueabi/8.2.0/crtendS.o <redacted>/build/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/crtn.o
    
    


    $ ls -Anl tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/libmcapi*
    lrwxrwxrwx 1 1001 1001    17 Jan 25 11:01 tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/libmcapi.so -> libmcapi.so.0.0.0
    lrwxrwxrwx 1 1001 1001    17 Jan 25 11:01 tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/libmcapi.so.0 -> libmcapi.so.0.0.0
    -rwxr-xr-x 3 1001 1001 38044 Jan 24 13:25 tmp/work/armv7at2hf-neon-poky-linux-gnueabi/mcapi-demo/1.0-r0/recipe-sysroot/usr/lib/libmcapi.so.0.0.0
    


    The recipe is trivial, as is the source:
    # MCAPI Demo recipe
    #
    DESCRIPTION="MCAPI demo"
    DEPENDS += "libmcapi-dev"
    LICENSE = "CLOSED"
    
    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
    
    SRC_URI = " \
        file://mcapi-demo.c  \
    "
    
    CFLAGS_append += " -v"
    CFLAGS_append += " -Wall"
    CFLAGS_append += " -Wpedantic"
    #CFLAGS_append += " -Werror"
    LDFLAGS_append += " -lmcapi"
    
    do_compile() {
        ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/mcapi-demo.c -o mcapi-demo
    }
    
    do_install() {
        install -d ${D}/home/root
        install -m 0755 ${S}/mcapi-demo ${D}/home/root
    }
    
    
    FILES_${PN} += " \
        /home/root/mcapi-demo \
    "


    #include <mcapi.h>
    #include <stdio.h>
    
    int main( int argc, char *argv[] )
    {
    	mcapi_info_t info = { 0 };
    	mcapi_status_t status;
    
        mcapi_initialize( 0, 0, NULL, NULL, &info, &status);
    
        printf( "mcapi_initialize:\n\tstatus = %u\n", status);
        printf( "\t= %u\n", info.mcapi_version);
        printf( "\t= %u\n", info.organization_id);
        printf( "\t= %u\n", info.implementation_version);
        printf( "\t= %u\n", info.number_of_domains);
        printf( "\t= %u\n", info.number_of_nodes);
        printf( "\t= %u\n", info.number_of_ports);
        printf( "\t= %p\n", (void *)info.impl_info);
    
        return 0;
    }

  • Hi rireland,

    Please make the following change in your recipe, It should build now.

    - ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/mcapi-demo.c -o mcapi-demo
    + ${CC} ${CFLAGS} ${WORKDIR}/mcapi-demo.c -o mcapi-demo ${LDFLAGS}

    Output:

    mcapi-demo/1.0-r0$ ls image/home/root/
    mcapi-demo

    Thanks
    Vignesh R

Reply Children