What is the gdbus library name? Technique to find it?

二次信任 提交于 2019-12-11 13:35:57

问题


What library do I need to include to use Bluez gdbus.h functions? I am getting alot of undefined reference errors for gdbus.h functions so I obviously I am missing a library.

*Is there a way (in terminal or otherwise) I can find out what library a header file uses? For example; I can find where a header file resides using locate gdbus.h. Is there a way I can find out what library gdbus.h requires?

My current pkg-config is:

pkg-config --cflags gio-2.0 dbus-glib-1 dbus-1 glib-2.0 gthread-2.0
pkg-config --libs gio-2.0 dbus-glib-1 dbus-1 glib-2.0 gthread-2.0

With this I get many undefined references such as:

agent.c:100: undefined reference to 'g_dbus_send_reply'
agent.c:104: undefined reference to 'g_dbus_send_reply'
agent.c:107: undefined reference to 'g_dbus_send_error'

What library am I missing?


回答1:


The gdbus functions are part of the gio library, so the gio-2.0 package is what you want.

The reason gdbus/gdbus.h isn't found is that it doesn't exist. I don't even have a package which provides a gdbus.h, much less gdbus/gdbus.h. The right file to include is gio/gio.h, which will include all the necessary headers for the entire gio library, including the 22 for gdbus.

Get rid of dbus-glib-1; it's deprecated (in favor of gdbus). If your code uses gdbus it's very unlikely it also requires dbus-glib.




回答2:


gbdus.h is located in the BlueZ user space source code, which in order to use, should be downloaded and maybe compiled.

http://git.kernel.org/cgit/bluetooth/bluez.git/tree/gdbus

The link above points to the folder that you're looking for in the source of this user space package. The header file is in there too. The file structure corresponds to the structure of the user space source code you should have downloaded. From there you can include the files you were missing.



来源:https://stackoverflow.com/questions/37495335/what-is-the-gdbus-library-name-technique-to-find-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!