ubuntu DBUS 收集
libdbus-1.so.3.19.11
是dbus-1.12.16.tar.gz 包编译出来的
参考文档:
https://www.freedesktop.org/wiki/Software/dbus/
https://www.freedesktop.org/wiki/IntroductionToDBus/
https://dbus.freedesktop.org/doc/dbus-tutorial.html
https://docs.gtk.org/gio/
https://docs.gtk.org/gio/migrating-gdbus.html
使用DBUS的软件 列表
https://www.freedesktop.org/wiki/Software/DbusProjects/
https://www.freedesktop.org/wiki/Software/DbusTools/
https://dbus.freedesktop.org/releases/dbus/
realse 版本
https://dbus.freedesktop.org/releases/dbus/
https://wiki.gnome.org/action/show/Apps/DFeet?action=show&redirect=DFeet
https://dbus.freedesktop.org/releases/dbus-glib/
Dbus 的编译(移植)以及双向通信使用例程
https://blog.youkuaiyun.com/qq_36731830/article/details/121865510
在图形界面中,
需要执行 在有界面的状态下执行 dbus-monitor
如果是在putty下面执行 : dbus-monitor
会出现问题:
Failed to open connection to session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
安装 D-BUS
安装D-Bus可在其官方网站下载源码编译,地址为http://dbus.freedesktop.org。
或者在终端上输入下列指令:
yum install dbus dbus-devel dbus-doc
安装后,头文件位于"/usr/include/dbus-<版本号>/dbus"目录中,编译使用D-Bus的程序时需加入编译指令"pkg-config --cflags --libs dbus-1
"。
执行指令
pkg-config --cflags --libs dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
D-Bus的用例
在使用GNOME桌面环境的Linux系统中,通常用GLib库提供的函数来管理总线。在测试下列用例前,首先需要安装GTK+开发包(见22.3节)并配置编译环境。该用例一共包含两个程序文件,每个程序文件需单独编译成为可执行文件。
1.消息发送程序
"dbus-ding-send.c"程序每秒通过会话总线发送一个参数为字符串Ding!的信号
main()函数创建一个GLib事件循环,获得会话总线的一个连接,并将D-Bus事件处理集成到GLib事件循环之中。然后它创建了一个名为 send_ding()函数作为间隔为一秒的计时器,并启动事件循环。send_ding()函数构造一个来自于对象路径"/com/burtonini /dbus/ding"和接口"com.burtonini.dbus.Signal"的新的Ding信号。然后,字符串Ding!作为参数添加到信号中 并通过总线发送。在标准输出中会打印一条消息以让用户知道发送了一个信号。
2.消息接收程序
dbus-ding-listen.c程序通过会话总线接收dbus-ding-send.c程序发送到消息
该程序侦听dbus-ping-send.c程序正在发出的信号。main()函数和前面一样启动,创建一个到总线的连接。然后它声明愿意在使用 com.burtonini.dbus.Signal接口的信号被发送时得到通知,将signal_filter()函数设置为通知函数,然后进入事件循 环。当满足匹配的消息被发送时,signal_func()函数会被调用。
如果需要确定在接收消息时如何处理,可通过检测消息头实现。若收到的消息为总线断开信号,则主事件循环将被终止,因为监听的总线已经不存在了。若收 到其他的消息,首先将收到的消息与期待的消息进行比较,两者相同则输出其中参数,并退出程序。两者不相同则告知总线并没有处理该消息,这样消息会继续保留 在总线中供别的程序处理。
好了,《dbus实例讲解》到此结束。其实我的所有文章只是希望能让这复杂的世界简单一点。
查看 dbus 版本
pkg-config --cflags --libs dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
pkg-config --modversion dbus-1
1.12.16
https://dbus.freedesktop.org/releases/dbus/dbus-1.12.16.tar.gz
编译 dbus-1.12.16
./configure --prefix=/home/jack/work/glib_study/dbus_study/install
./configure -prefix=/home/ubuntu/dbus-1.13.18/install
make && make install
https://developer.gnome.org/gio/stable/gdbus-convenience.html
http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
the GNOME and KDE desktops
make install 之后:
安装 d-feet
sudo apt-get install d-feet
【dbus_00】dbus在ubuntu18.04上的安装
https://blog.youkuaiyun.com/Kevin__Mei/article/details/89484314
3
1.首先,D-bus可以分成三部分来看,
(1)dbus-daemon,一个dbus的后台守护程序,用于多个应用之间消息的转发;
(2)libdbus.so,dbus的功能接口,当你的程序需要使用dbus时,其实就是调用libdbus.so里面的接口;
(3)高层封装,如dbus-glib和QT D-bus,这些其实都对D-bus的再封装,让你使用起来更方便。
从D-bus官网下载到源码,其实只包含上面所说的1和2两部分,libdbus.so里面的接口也就是官网说的low-level API。
官网:http://www.freedesktop.org/wiki/Software/dbus/
经典例子:http://www.matthew.ath.cx/articles/dbus
不错的帖子:http://blog.youkuaiyun.com/flowingflying/article/details/4527634
4
gcc 未定义对 dbus_* 的引用
$ gcc `pkg-config --libs --cflags dbus-1` hh.c -o hh
/tmp/ccMabXOg.o: In function `main':
hh.c:(.text+0x18): undefined reference to `dbus_error_init'
hh.c:(.text+0x29): undefined reference to `dbus_bus_get'
hh.c:(.text+0x39): undefined reference to `dbus_error_is_set'
hh.c:(.text+0x5f): undefined reference to `dbus_error_free'
hh.c:(.text+0x80): undefined reference to `dbus_bus_name_has_owner'
hh.c:(.text+0x8f): undefined reference to `dbus_error_is_set'
hh.c:(.text+0x9f): undefined reference to `dbus_error_free'
hh.c:(.text+0xfb): undefined reference to `dbus_bus_request_name'
hh.c:(.text+0x10a): undefined reference to `dbus_error_is_set'
hh.c:(.text+0x11a): undefined reference to `dbus_error_free'
collect2: error: ld returned 1 exit status
您的链接顺序是从后到前的。代替:
gcc pkg-config --libs --cflags dbus-1
hh.c -o hh
做:
gcc hh.c -o hh pkg-config --libs --cflags dbus-1
或者:
gcc hh.c pkg-config --libs --cflags dbus-1
-o hh
在链接序列中,需要符号定义的文件必须位于提供定义的文件之前。所以库在目标文件之后。