Re: Linkage Zephyr V1.13 versus V2.X

Lawrence King

I had the same issue when moving forward kernel versions. The API for


At the top level get rid of the bt_gatt_ccc_cfg variables (my code has two characteristics) :


#ifndef NEW_BT_STACK

static struct bt_gatt_ccc_cfg iks_atom_ccc_cfg[BT_GATT_CCC_MAX];

static struct bt_gatt_ccc_cfg iks_mtoa_ccc_cfg[BT_GATT_CCC_MAX];



And inside the bt_gatt_attr change the parameters to the BT_GATT_CCC macro, delete the first parameter it is no longer needed, and add a new 3rd parameter (same thing in two places for me):


#ifdef  NEW_BT_STACK


        // BT_GATT_CCC(iks_atom_ccc_cfg_changed,BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),

        // BT_GATT_CCC(iks_atom_ccc_cfg_changed,BT_GATT_PERM_READ | BT_GATT_PERM_WRITE_ENCRYPT),

#else   //NEW_BT_STACK

        BT_GATT_CCC(iks_atom_ccc_cfg, iks_atom_ccc_cfg_changed),

#endif  //NEW_BT_STACK


Lawrence King

Principal Developer



From: devel@... <devel@...> On Behalf Of frv
Sent: Wednesday, December 4, 2019 2:19 AM
To: devel@...
Subject: [Zephyr-devel] Linkage Zephyr V1.13 versus V2.X


[Edited Message Follows]

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.





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)



FILE(GLOB app_sources src/*.c)

target_sources(app PRIVATE





//has the button.h file



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 :


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.



Best regards,


Join to automatically receive all group messages.