Linkage Zephyr V1.13 versus V2.X


frv
 
Edited

Hi all,
 
Recently I have moved from Zephyr 1.13 to V2.
 
I ported my simple BLE peripheral application based on the sample code peripheral_hr from  V1.13 to V2.
 
However I can't seem to get it build anymore due to a linkage issue.
As far as I can see the sources are well compiled but for some reason the linker reports an undefined reference.
 
"/home/frv/develop/zephyrproject/zephyr/samples/bluetooth/peripheral_hrORIGI/src/button.c:78: undefined reference to `bt_gatt_service_register'"
 
In my setup the GATT services are still defined in separate files. 
So next to my main.c that calls the init function (button_init()) I have the sources button.c and button.h file where I define my own GATT service (cfr. hrs.c, hrs.h as done in V1.13) to follow up a button press.
 
src/main.c
    /button.c
 
The CMakeLists.txt has as content (which is pretty simple): 
 
# SPDX-License-Identifier: Apache-2.0
 
cmake_minimum_required(VERSION 3.13.1)
 
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(peripheral_hr)
 
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE
  ${app_sources}
  )
 
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth)
//has the button.h file
zephyr_library_include_directories($ENV{ZEPHYR_BASE}/samples/bluetooth/gatt)
 
In the button.c  code snippet:
...
static struct bt_gatt_service button_svc = BT_GATT_SERVICE(attrs);
 
void button_init(void)
{
   int result = bt_gatt_service_register(&button_svc);
}
...
 
I have spend some time on looking at the boilerplate concepts but so far without any luck to prevent the linker error.
I also had a look at this : https://github.com/zephyrproject-rtos/zephyr/issues/8851
 
Any idea's what the issue could be and how to solve this properly. Linkage order?
 
BTW when I do the call, bt_gatt_service_register,  in the main.c this is not seen as an undefined reference.
 
Thanks,
Best regards,
Frank

Join devel@lists.zephyrproject.org to automatically receive all group messages.