peripheral_gatt_write.c:105: undefined reference to `last_write_rate' when creating new application from bluetooth/peripheral_gatt_write sample

Hi,

I'm working on:

  • Mac mini M1
  • macOS Ventura 13.1

In Visual Studio Code (1.74.2) / nRF Connect extension, I create new application with following params:

  • nRF Connect SDK: 2.2.0 (/opt/nordic/ncs/v2.2.0)
  • nRF Connect Toolchain: 2.2.0 (/opt/nordic/ncs/toolchains/v2.2.0)
  • Application location: /Users/myname/apps
  • Application template: zephyr/samples/bluetooth/peripheral_gatt_write
  • Application name: peripheral_gatt_write

When building, this error occurs:

/opt/nordic/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /Users/myname/apps/peripheral_gatt_write/src/peripheral_gatt_write.c:105: undefined reference to `last_write_rate'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/v2.2.0/bin/cmake --build /Users/quan/Documents/nordic/Implementations/peripheral_gatt_write/build

I have not modified the code yet, but the compiler hits this error.

How should I fix this?

Parents
  • Hi, 

    Because the CMakeList would look for ../central_gatt_write/src/gatt_write_common.c, you could copy v2.2.0\zephyr\samples\bluetooth\central_gatt_write to /Users/myname/apps or update the CMakeList Line.8 as 

    FILE(GLOB app_sources src/*.c C:/ncs/v2.2.0/zephyr/samples/bluetooth/central_gatt_write/src/gatt_write_common.c)

    Regards,
    Amanda H.

  • Thanks a lot, Amanda. It works magically.

    By the way, for those that still get this issue, I'd like to post my CMakeTLists.txt for those who still get this issue:

    # SPDX-License-Identifier: Apache-2.0
    
    cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(peripheral_gatt_write)
    
    FILE(GLOB app_sources
       src/*.c
       ${ZEPHYR_BASE}/samples/bluetooth/central_gatt_write/src/gatt_write_common.c
    )
    
    target_sources(app PRIVATE
       ${app_sources}
    )
    
    zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)

    Best regards,

Reply
  • Thanks a lot, Amanda. It works magically.

    By the way, for those that still get this issue, I'd like to post my CMakeTLists.txt for those who still get this issue:

    # SPDX-License-Identifier: Apache-2.0
    
    cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(peripheral_gatt_write)
    
    FILE(GLOB app_sources
       src/*.c
       ${ZEPHYR_BASE}/samples/bluetooth/central_gatt_write/src/gatt_write_common.c
    )
    
    target_sources(app PRIVATE
       ${app_sources}
    )
    
    zephyr_library_include_directories(${ZEPHYR_BASE}/samples/bluetooth)

    Best regards,

Children
No Data
Related