Header Files not adding

Hi there,

I can't seem to add header files to my project. 

The header files underlined in red are not from the Nordic SDK installed from the Toolchain Manager.

I have the header files added in an inc folder and the path in the c_cpp_properties.json file.

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/nordicToolchain/myapps/uart_test/inc/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64",
            "configurationProvider": "nrf-connect"
        }
    ],
    "version": 4
}

Here's the error code:

[78/161] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj 
C:\nordicToolchain\v1.9.1\toolchain\opt\bin\arm-none-eabi-gcc.exe -DBUILD_VERSION=v2.7.99-ncs1-1 -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=0 -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/nordicToolchain/v1.9.1/zephyr/include -Izephyr/include/generated -IC:/nordicToolchain/v1.9.1/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/nordicToolchain/v1.9.1/zephyr/soc/arm/nordic_nrf/common/. -IC:/nordicToolchain/v1.9.1/nrf/include -IC:/nordicToolchain/v1.9.1/modules/hal/cmsis/CMSIS/Core/Include -IC:/nordicToolchain/v1.9.1/modules/hal/nordic/nrfx -IC:/nordicToolchain/v1.9.1/modules/hal/nordic/nrfx/drivers/include -IC:/nordicToolchain/v1.9.1/modules/hal/nordic/nrfx/mdk -IC:/nordicToolchain/v1.9.1/zephyr/modules/hal_nordic/nrfx/. -IC:/nordicToolchain/v1.9.1/modules/debug/segger/SEGGER -IC:/nordicToolchain/v1.9.1/modules/debug/segger/Config -IC:/nordicToolchain/v1.9.1/zephyr/modules/segger/. -isystem C:/nordicToolchain/v1.9.1/zephyr/lib/libc/minimal/include -isystem c:/nordictoolchain/v1.9.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include -isystem c:/nordictoolchain/v1.9.1/toolchain/opt/bin/../lib/gcc/arm-none-eabi/9.2.1/include-fixed -isystem C:/nordicToolchain/v1.9.1/nrfxlib/crypto/nrf_cc310_platform/include -Os -imacros C:/nordicToolchain/myapps/uart_test/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -imacros C:/nordicToolchain/v1.9.1/zephyr/include/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-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=C:/nordicToolchain/myapps/uart_test=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/nordicToolchain/v1.9.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/nordicToolchain/v1.9.1=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
c:\nordicToolchain\myapps\uart_test\src\main.c:19:10: fatal error: app_uart.h: No such file or directory
   19 | #include "app_uart.h"
      |          ^~~~~~~~~~~~
compilation terminated.
[79/161] Linking C static library zephyr\drivers\serial\libdrivers__serial.a
[80/161] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
[81/161] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_packaged.c.obj
[82/161] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/nordicToolchain/v1.9.1/modules/hal/nordic/nrfx/drivers/src/nrfx_ppi.c.obj
[83/161] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
[84/161] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/C_/nordicToolchain/v1.9.1/modules/hal/nordic/nrfx/drivers/src/nrfx_gpiote.c.obj
[85/161] Linking C static library modules\nrf\lib\fatal_error\lib..__nrf__lib__fatal_error.a
[86/161] Linking C static library modules\nrf\drivers\hw_cc310\lib..__nrf__drivers__hw_cc310.a
[87/161] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\nordicToolchain\v1.9.1\toolchain\opt\bin\cmake.EXE' --build 'c:\nordicToolchain\myapps\uart_test\build'
The terminal process terminated with exit code: 1.

Thanks in advance!

  • Hello!

    What exactly are you trying to add to your project?

    It looks like you might be trying to add libraries from a different SDK, maybe to port a project you had in an old SDK over to NCS?

    If that is the case, I would advise you to not use those old libraries and instead use the libraries that are available to you in Zephyr, such as UARTscheduling, etc.

    Though if you still want to include your own header files, then I haven't seen json files like these used in Zephyr.

    Have a look at the typical Zephyr project structure illustrated here.

    You could try to point cmake towards your source code using the target_sources build script in CMakeLists.txt as described here.

    But only if you're trying to include your own header files, please do not try to include header files from old SDKs outside NCS.

    Best regards,

    Einar

Related