Creating new C file in a Exemple project

I'm currently developing a project using the Audio NRF5340 to communicate over BLE. All the modifications I made to the Audio DK app work in VScode with SDK 2.9.0, but recently I wanted to implement GTBS services. So I added a C file and its header. Since then, I haven't been able to compile it, only having issues with the linker and the include function.

Is there a special procedure for creating a new C file with a header?


  • Try Click build and see report in TERMINAL instead of wating PROBLEMS

  • Hello, 

    Have you seen our Developer Academy and the nRF Connect SDK fundamentals course? This is a good course to start with and learn the basics of our NCS. 

    We recommend looking at build log in the terminal as pointed out by  . 

    Kind regards,
    Øyvind

  • Do you modify CMakeLists.txt?

    # NORDIC SDK APP START
    target_sources(app PRIVATE
      src/main.c
    )
    # NORDIC SDK APP END

  • herre is the terminal :

    -- libmetal version: 1.6.0 (C:/Users/p129807/Main_Project_BLE/nrf5340_audio)
    -- Build type:  MinSizeRel
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- open-amp version: 1.6.1 (C:/ncs/v2.9.0/modules/lib/open-amp/open-amp)
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- C_FLAGS :  -Wall -Wextra
    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:2133 (message):
      __ASSERT() statements are globally ENABLED
    
    
    CMake Warning at C:/ncs/v2.9.0/zephyr/CMakeLists.txt:2164 (message):
      
    
            The CMake build type was set to 'MinSizeRel', but the optimization flag was set to '-Og'.
            This may be intentional and the warning can be turned off by setting the CMake variable 'NO_BUILD_TYPE_WARNING'
    
    
    -- Configuring done
    CMake Error at C:/ncs/v2.9.0/zephyr/cmake/modules/extensions.cmake:457 (add_library):
      Cannot find source file:
    
        //bt_tbs.c
    Call Stack (most recent call first):
      C:/ncs/v2.9.0/zephyr/cmake/modules/kernel.cmake:218 (zephyr_library_named)
      C:/ncs/v2.9.0/zephyr/cmake/modules/zephyr_default.cmake:142 (include)
      C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
      CMakeLists.txt:13 (find_package)
    
    
    -- Generating done
    CMake Generate step failed.  Build files cannot be regenerated correctly.
    FAILED: build.ninja 
    C:\ncs\toolchains\b620d30767\opt\bin\cmake.exe --regenerate-during-build -SC:\Users\p129807\Main_Project_BLE\nrf5340_audio -BC:\Users\p129807\Main_Project_BLE\nrf5340_audio\build_2\nrf5340_audio
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\b620d30767\opt\bin\cmake.EXE' --build C:/Users/p129807/Main_Project_BLE/nrf5340_audio/build_2/nrf5340_audio

  • Did you try what  suggested? You can find more information in our documentation on Adding files and configuring CMake.

    Kind regards,
    Øyvind

Related