boilerplate.cmake not found because ZEPHYR_BASE isn't set

Hi,

I'm very confused by this error.

I have a project with the following CMakeLists.txt file

cmake_minimum_required(VERSION 3.20.0)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bike_finder)

target_sources(app PRIVATE src/main.c)
//... more target sources

# NORDIC SDK APP END
zephyr_library_include_directories(.)

When the project is tried to be built at the startup of VScode, I get the following error message

When I open a terminal, I ran echo $ZEPHYR_BASE, but it came out empty.
Therefore, I go into the nRF Connect SDK folder that I'm using (v2.2.0-rc1), run source zephyr/zephyr-env.sh and then the terminal finally recognizes where ZEPHYR_BASE is.

To rebuild, I just do a dummy modification to the file (use :w since I'm using vim within vscode), and then application tries to rebuild again, but I keep the same error.

If I go to the nRF Connect extension section, I see my folder under applications, but it's followed by "no build configurations", because of this problem.

What should I do?

Parents Reply
  • Ok, I managed to fix the boards problem. It seems that removing the cmake extension allowed me to work through it.

    However, now I'm having still one more problem, the following lines in my main.c are failing due to not being able to locate these files:

    #include<zephyr.h>

    #include<sys/printk.h>

    Again, opening the terminal from the toolchain manager outputs the correct location for the zephyr folder:
    /home/ernesto/ncs/v2.2.0-rc1/zephyr

    And I have made sure that both files exist in said directory.

    In the compilation command, I see the following directory included with -I (besides many others, ofc):
    -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/include

    Now, the zephyr.h is in .../zephyr/include/zephyr

    So I wonder whether the -I statement up to .../include is enough, or should it be extended up to zephyr as well? If so, how can I include that?

Children
  • Hi,

    Regarding the board name, I am sorry for the confusion. You mentioned nRF52832-DK, so it could be that you meant either nRF52-DK (which has nRF52832) or you mistyped nRF52833-DK. 

    Could you send log output of the build process?

    Best regards,
    Dejan

  • I see, my bad.
    This is the output log of the building process:

     *  Executing task: nRF Connect: Build: bike_finder/build (active) 
    
    Building bike_finder
    west build --build-dir /home/ernesto/ncs/bike_finder/build /home/ernesto/ncs/bike_finder
    
    [1/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/multi_heap.c.obj
    [2/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
    [3/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/bitarray.c.obj
    [4/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
    [5/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
    [6/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_complete.c.obj
    [7/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
    [8/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/assert.c.obj
    [9/198] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
    [10/198] Building C object CMakeFiles/app.dir/src/main.c.obj
    FAILED: CMakeFiles/app.dir/src/main.c.obj 
    ccache /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D__PROGRAM_START -D__ZEPHYR__=1 -I../. -I/home/ernesto/ncs/v2.2.0-rc1/nrf/drivers/mpsl/clock_control -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/include -Izephyr/include/generated -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/soc/arm/nordic_nrf/common/. -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/subsys/bluetooth -I/home/ernesto/ncs/v2.2.0-rc1/nrf/include -I/home/ernesto/ncs/v2.2.0-rc1/nrf/lib/multithreading_lock/. -I/home/ernesto/ncs/v2.2.0-rc1/nrf/subsys/bluetooth/controller/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/cmsis/CMSIS/Core/Include -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx/drivers/include -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx/mdk -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/modules/hal_nordic/nrfx/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/debug/segger/SEGGER -I/home/ernesto/ncs/v2.2.0-rc1/modules/debug/segger/Config -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/modules/segger/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/crypto/tinycrypt/lib/include -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/mpsl/include -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/mpsl/include/protocol -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/softdevice_controller/include -isystem /home/ernesto/ncs/v2.2.0-rc1/zephyr/lib/libc/minimal/include -isystem /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -fno-strict-aliasing -Os -imacros /home/ernesto/ncs/bike_finder/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/ernesto/ncs/v2.2.0-rc1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/ernesto/ncs/bike_finder=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ernesto/ncs/v2.2.0-rc1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ernesto/ncs/v2.2.0-rc1=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
    /home/ernesto/ncs/bike_finder/src/main.c:7:10: fatal error: zephyr.h: No such file or directory
        7 | #include <zephyr.h>
          |          ^~~~~~~~~~
    compilation terminated.
    [11/198] Building C object CMakeFiles/app.dir/services/buzzer_service.c.obj
    FAILED: CMakeFiles/app.dir/services/buzzer_service.c.obj 
    ccache /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52832_XXAA -DUSE_PARTITION_MANAGER=0 -D__PROGRAM_START -D__ZEPHYR__=1 -I../. -I/home/ernesto/ncs/v2.2.0-rc1/nrf/drivers/mpsl/clock_control -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/include -Izephyr/include/generated -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/soc/arm/nordic_nrf/common/. -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/subsys/bluetooth -I/home/ernesto/ncs/v2.2.0-rc1/nrf/include -I/home/ernesto/ncs/v2.2.0-rc1/nrf/lib/multithreading_lock/. -I/home/ernesto/ncs/v2.2.0-rc1/nrf/subsys/bluetooth/controller/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/cmsis/CMSIS/Core/Include -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx/drivers/include -I/home/ernesto/ncs/v2.2.0-rc1/modules/hal/nordic/nrfx/mdk -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/modules/hal_nordic/nrfx/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/debug/segger/SEGGER -I/home/ernesto/ncs/v2.2.0-rc1/modules/debug/segger/Config -I/home/ernesto/ncs/v2.2.0-rc1/zephyr/modules/segger/. -I/home/ernesto/ncs/v2.2.0-rc1/modules/crypto/tinycrypt/lib/include -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/mpsl/include -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/mpsl/include/protocol -I/home/ernesto/ncs/v2.2.0-rc1/nrfxlib/softdevice_controller/include -isystem /home/ernesto/ncs/v2.2.0-rc1/zephyr/lib/libc/minimal/include -isystem /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include -isystem /home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/include-fixed -fno-strict-aliasing -Os -imacros /home/ernesto/ncs/bike_finder/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/ernesto/ncs/toolchains/v2.2.0-rc1/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/ernesto/ncs/v2.2.0-rc1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/ernesto/ncs/bike_finder=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/ernesto/ncs/v2.2.0-rc1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/ernesto/ncs/v2.2.0-rc1=WEST_TOPDIR -ffunction-sections -fdata-sections -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/services/buzzer_service.c.obj -MF CMakeFiles/app.dir/services/buzzer_service.c.obj.d -o CMakeFiles/app.dir/services/buzzer_service.c.obj -c ../services/buzzer_service.c
    /home/ernesto/ncs/bike_finder/services/buzzer_service.c:5:10: fatal error: sys/printk.h: No such file or directory
        5 | #include <sys/printk.h>
          |          ^~~~~~~~~~~~~~
    compilation terminated.
    [12/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/reboot.c.obj
    [13/198] Building ASM object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/common/soc_nrf_common.S.obj
    [14/198] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_enabled_instances.c.obj
    [15/198] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/mpsc_pbuf.c.obj
    [16/198] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_cache.c.obj
    [17/198] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nordic_nrf/validate_base_addresses.c.obj
    [18/198] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_mgmt.c.obj
    [19/198] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_core.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /home/ernesto/ncs/toolchains/v2.2.0-rc1/usr/local/bin/cmake --build /home/ernesto/ncs/bike_finder/build
    
     *  The terminal process failed to launch (exit code: 1). 
     *  Terminal will be reused by tasks, press any key to close it. 

  • Hi,

    Is this output log from VS Code or from the terminal which is started using Toolchain Manager?

    Best regards,
    Dejan

  • from VS Code after I press build on the nrf connect extension.

  • Hi,

    Could you try using "west build" command from the terminal opened from Toolchain Manager?

    Best regards,
    Dejan

Related