This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

external_lib not compiling out of the box

I am trying to get external_lib example application to compile for NRF5340pdk. I am using nRF Connect SDK v1.4.1 and picked the example provided in zepher/samples/application_development/external_lib. The code does not compile and does not seem to give any obvious errors. I am using a windows 10 PC for development. Do I need to do something more to get it to compile and run?

  • Hello,

    Sorry for the delayed response. I tried building with both SES 5.10d and West in NCS 1.4.1, but I did not manage to replicate the build problem here, so I'm not really sure what the problem could be. Below is the build log I got for comparison.

    C:\ncs\v1.4.1\zephyr\samples\application_development\external_lib>west build -b nrf5340pdk_nrf5340_cpuapp -p
    -- west build: generating a build system
    Including boilerplate (Zephyr base): C:/ncs/v1.4.1/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib
    -- Using NCS Toolchain 1.4.0 for building. (C:/ncs/v1.4.1/toolchain/cmake)
    -- Zephyr version: 2.4.0 (C:/ncs/v1.4.1/zephyr)
    -- Found Python3: C:/ncs/v1.4.1/toolchain/opt/bin/python.exe (found suitable exact version "3.8.2") found components:  Interpreter
    -- Found west (found suitable version "0.7.2", minimum required is "0.7.1")
    -- Board: nrf5340pdk_nrf5340_cpuapp
    -- Cache files will be written to: C:/ncs/v1.4.1/zephyr/.cache
    -- Found dtc: C:/ncs/v1.4.1/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found toolchain: gnuarmemb (C:/ncs/v1.4.1/toolchain/opt)
    -- Found BOARD.dts: C:/ncs/v1.4.1/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts
    -- Generated zephyr.dts: C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/include/generated/devicetree_unfixed.h
    Parsing C:/ncs/v1.4.1/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v1.4.1/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340pdk_nrf5340_cpuapp_defconfig'
    Merged configuration 'C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/prj.conf'
    Configuration saved to 'C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/.config'
    Kconfig header saved to 'C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 9.2.1
    -- The CXX compiler identification is GNU 9.2.1
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/v1.4.1/toolchain/opt/bin/arm-none-eabi-gcc.exe
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build
    -- west build: building application
    [6/144] Performing build step for 'mylib_project'
    mkdir -p C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/mylib/obj C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/mylib/lib
    C:/ncs/v1.4.1/toolchain/opt/bin/arm-none-eabi-gcc.exe -c -IC:/ncs/v1.4.1/zephyr/include -IC:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/include/generated -IC:/ncs/v1.4.1/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v1.4.1/zephyr/lib/libc/minimal/include -IC:/ncs/v1.4.1/nrf/include -IC:/ncs/v1.4.1/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v1.4.1/modules/hal/nordic/nrfx -IC:/ncs/v1.4.1/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v1.4.1/modules/hal/nordic/nrfx/mdk -IC:/ncs/v1.4.1/modules/hal/nordic/. -Ic:/users/vibe/ncs/v1.4.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -Ic:/users/vibe/ncs/v1.4.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -DKERNEL -D__ZEPHYR__=1 -D_FORTIFY_SOURCE=2 -DBUILD_VERSION=v2.4.0-ncs2 -DUSE_PARTITION_MANAGER=0 -D__PROGRAM_START -DNRF5340_XXAA_APPLICATION  -Os -imacros C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mcpu=cortex-m33 -mthumb -mabi=aapcs -imacros C:/ncs/v1.4.1/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v1.4.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v1.4.1=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -isystemC:/ncs/v1.4.1/zephyr/lib/libc/minimal/include -isystemc:/users/vibe/ncs/v1.4.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystemc:/users/vibe/ncs/v1.4.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -MD -Iinclude src/mylib.c -o C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/mylib/obj/mylib.o
    C:/ncs/v1.4.1/toolchain/opt/bin/arm-none-eabi-ar.exe -rcs C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/mylib/lib/libmylib.a C:/ncs/v1.4.1/zephyr/samples/application_development/external_lib/build/mylib/obj/mylib.o
    [139/144] Linking C executable zephyr\zephyr_prebuilt.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       20788 B         1 MB      1.98%
                SRAM:        5648 B       448 KB      1.23%
            IDT_LIST:          56 B         2 KB      2.73%
    [144/144] Linking C executable zephyr\zephyr.elf

    If you are still getting this error, could you maybe try to install NCS v1.4.99-dev1 through the toolchain manager and see if it gives you the same result?

  • Thanks Vidar. I am using NCS 1.4.0, I get the following error:


    [6/144] Performing build step for 'mylib_project'
    FAILED: mylib/src/mylib_project-stamp/mylib_project-build mylib/lib/libmylib.a
    cmd.exe /C "cd /D C:\Users\ahebbar539\ncs\v1.4.1\zephyr\samples\application_development\external_lib\mylib && make PREFIX

    For some reason, it looks like the Makefile command:

    mkdir -p ./obj ./lib
    The syntax of the command is incorrect 

    could be the problem. I got the above when I run the make command. 

  • Thanks, your log pointed me in the right direction. Turns out the mkdir executable included with the ncs toolchain (in v1.4.1\toolchain\usr\bin\) does not support any of the option arguments for some reason (i.e. -p, -m, --help), which I have reported now. The reason I didn't get the error was that I already had a working version of mkdir installed on my system ( from this package) in addition to the one in the NCS toolchain.

    Please try to replace executable in v1.4.1\toolchain\usr\bin\ with one that works.

  • Hi Vidar, thanks for the pointer. The mkidir you pointed to worked, though I had to play around with the paths a little bit. 

  • Thank you for the update. I'm glad to hear that it works now. I have reported it as a bug, so it will hopefully get fixed in time for the next SDK release.

Related