linux使用dbus

  • A+
所属分类:linux技术
摘要

前提是已经安装了dbus编写server.c和client.c编译ubuntu@VM-0-8-ubuntu:~/dbus-1.13.18/install/test$ gcc server.c -I ../../ -ldbus-1 -L ../lib/ –lpthread

前提是已经安装了dbus

编写server.c和client.c

编译

ubuntu@VM-0-8-ubuntu:~/dbus-1.13.18/install/test$ gcc server.c -I ../../ -ldbus-1 -L ../lib/ –lpthread

获取DBUS_SESSION_BUS_ADDRESS

ubuntu@VM-0-8-ubuntu:~$ dbus-launch
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cEvKyeNF2G,guid=ea9b6fc2f80c05360b70be8e5fdc20a3
DBUS_SESSION_BUS_PID=31602

设置环境变量

export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cEvKyeNF2G,guid=ea9b6fc2f80c05360b70be8e5fdc20a3