Incorrect static library link order in CubeMX generated BLE CMake project for STM32WBA
Hello,
When generating a basic Bluetooth project for NUCLEO‑WBA55CG using STM32CubeMx 6.17 (and 6.16) with Cmake as the toolchain, the project compilation fails to a missing symbol during the link stage.
Here is the error message:
le_ctrl.c:(.text.HCI_READ_LOCAL_VERSION_INFORMATION+0x20): undefined reference to `ll_sys_get_brief_fw_version'
After investigation, it turns out the issue is caused by the incorrect order of linked static BLE libraries in the generated CMake file "cmake/stm32cubemx/CMakeLists.txt". CubeMX places the Link Layer and BLE Stack libraries in an order that prevents the linker from resolving symbols correctly. Reordering the libraries fixes the issue.
Here is the corrected order that resolves the error:
# Project static libraries
set(MX_LINK_LIBS
:stm32wba_ble_stack_basic.a
:WBA5_LinkLayer_BLE_Basic_lib.a
STM32_Drivers
${TOOLCHAIN_LINK_LIBRARIES}
Utilities
STM32_WPAN
Common
)
Best regards
