Question

I am coding plugin for Bluez 5.18 in C, I want create my own BLE GATT profile as plugin (shared library). I need call function from main code, when I complile it, there is no error, but while loading plugin, it crash on undefined symbol - unsatisfied reference to function (for example gatt_service_add). But some functions are accessible from main program - all functions with prefix "btd_".

When I list symbols from main program using nm program, functions with prefix "btd_" are global symbols (T mark in list) and functions as "gatt_service_add" is local symbol (t mark in list)

So my question is, how can I use functions like "gatt_service_add" in my plugin without undefined symbol error? Am I missing some parameters while compiling? Note that I cant change main program, so I need solution only for my plugin. Using only functions with "btd_" prefix I dont know how to create working own gatt profile etc... so acceptable solution can be also working gatt profile only with accessible functions ("btd_" prefix + some help functions from /lib)

I complile my plugin with this parameters:

gcc -DHAVE_CONFIG_H -I/usr/include/glib-2.0 -I/usr/include/dbus-1.0 -I/usr/include/bluetooth -I/usr/lib/dbus-1.0/include -I/usr/lib/glib-2.0/include -I"/home/<user>/Workspace/bluez" -O3 -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"gatt-example.d" -MT"gatt-example.d" -o "gatt-example.o" "../gatt-example.c"
gcc -Wl,-E -shared -o "bluez-plugin.so"  ./gatt-example.o  /home/<user>/Workspace/bluez/lib/.libs/libbluetooth-internal.a -ldbus-1 -lglib-2.0
Was it helpful?

Solution 2

For now, you cant create BLE GATT profile as external plugin in Bluez 5.18 (also in 5.19), and it is only possible using builtin plugin

Bluez mailing list

OTHER TIPS

Local symbols cannot be accessed by other modules. That's the very definition of local symbols. You are missing no compiler flags, it's just not possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top