Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

undefined reference to `log_strdup'

I'm following the tutorial on youtube of Nordic Semiconductor called "Developing Bluetooth Low Energy products using nRF Connect SDK" ( here the link https://www.youtube.com/watch?v=hY_tDext6zA&t=386s ).
At the end of the tutorial, when I have to build the final code, I get this error:

" D:\nordic\01_Bluetooth_LE_tutorial\bluetooth_remote\src\main.c:77: undefined reference to `log_strdup'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.1.0\opt\bin\cmake.EXE' --build 'd:\nordic\01_Bluetooth_LE_tutorial\bluetooth_remote\build' "

On the video instead there are no errors. I followed all the steps, but to be shure I tried also to download the final solution from the link in description but I got the same error and i can't build and test the program. What can I do?


I put here the entire message from the terminal:

FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
cmd.exe /C "cd . && C:\ncs\toolchains\v2.1.0\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr\zephyr_pre0.elf -Wl,-T zephyr/linker_zephyr_pre0.cmd -Wl,-Map=D:/nordic/01_Bluetooth_LE_tutorial/bluetooth_remote/build/zephyr/zephyr_pre0.map -Wl,--whole-archive app/libapp.a zephyr/libzephyr.a zephyr/arch/common/libarch__common.a zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a zephyr/arch/arch/arm/core/aarch32/mpu/libarch__arm__core__aarch32__mpu.a zephyr/lib/libc/minimal/liblib__libc__minimal.a zephyr/lib/posix/liblib__posix.a zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a zephyr/soc/arm/nordic_nrf/nrf52/libsoc__arm__nordic_nrf__nrf52.a zephyr/subsys/bluetooth/common/libsubsys__bluetooth__common.a zephyr/subsys/bluetooth/host/libsubsys__bluetooth__host.a zephyr/subsys/net/libsubsys__net.a zephyr/subsys/random/libsubsys__random.a zephyr/drivers/clock_control/libdrivers__clock_control.a zephyr/drivers/console/libdrivers__console.a zephyr/drivers/gpio/libdrivers__gpio.a zephyr/drivers/serial/libdrivers__serial.a zephyr/drivers/entropy/libdrivers__entropy.a zephyr/drivers/timer/libdrivers__timer.a zephyr/drivers/pinctrl/libdrivers__pinctrl.a modules/nrf/lib/dk_buttons_and_leds/lib..__nrf__lib__dk_buttons_and_leds.a modules/nrf/lib/multithreading_lock/lib..__nrf__lib__multithreading_lock.a modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a modules/nrf/subsys/bluetooth/controller/lib..__nrf__subsys__bluetooth__controller.a modules/nrf/subsys/mpsl/init/lib..__nrf__subsys__mpsl__init.a modules/nrf/drivers/mpsl/clock_control/lib..__nrf__drivers__mpsl__clock_control.a modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a -Wl,--no-whole-archive zephyr/kernel/libkernel.a zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -L"c:/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/thumb/v7e-m/nofp" -LD:/nordic/01_Bluetooth_LE_tutorial/bluetooth_remote/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a C:/ncs/v2.1.0/nrfxlib/crypto/nrf_oberon/lib/cortex-m4/soft-float/liboberon_3.0.12.a -no-pie -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn C:/ncs/v2.1.0/nrfxlib/mpsl/lib/cortex-m4/soft-float/libmpsl.a C:/ncs/v2.1.0/nrfxlib/softdevice_controller/lib/cortex-m4/soft-float/libsoftdevice_controller_peripheral.a && cmd.exe /C "cd /D D:\nordic\01_Bluetooth_LE_tutorial\bluetooth_remote\build\zephyr && C:\ncs\toolchains\v2.1.0\opt\bin\cmake.exe -E echo ""
c:/ncs/toolchains/v2.1.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/10.3.0/../../../../arm-zephyr-eabi/bin/ld.exe: app/libapp.a(main.c.obj): in function `on_data_received':
D:\nordic\01_Bluetooth_LE_tutorial\bluetooth_remote\src\main.c:77: undefined reference to `log_strdup'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

The function in whitch i use "log_strdup" is this one:

void on_data_received(struct bt_conn *conn, const uint8_t *const data, uint16_t len)
{
    uint8_t temp_str[len+1];
    memcpy(temp_str, data, len);
    temp_str[len] = 0x00;

    LOG_INF("Received data on conn %p. Len: %d", (void *)conn, len);
    LOG_INF("Data: %s", log_strdup(temp_str));
}

Im using a nRF52 development kit with a nRF52832, nRF connect SDK v2.1.0
OS: Windows 11

Parents Reply Children
No Data
Related