【问题标题】:X11 Dependency, Compile Dbus without X11, starting only Shell C++ Applications Raspbian LinuxX11 依赖,不使用 X11 编译 Dbus,只启动 Shell C++ Applications Raspbian Linux
【发布时间】:2014-04-16 06:52:50
【问题描述】:

尊敬的 SO 社区您好 :)

我正在尝试让 DBus 在我的 Raspberry Pi 上运行。 当我在 Pi 桌面环境中时,来自 libdbus-c++-1 的示例代码运行良好 -> (startx)

我在互联网上的研究以及我在 stackoverflow 上找到的示例对我没有帮助:[.

但是,当我处于 Shell 模式时,我会收到错误消息

./client
terminate called after throwing an instance of 'DBus::Error'
  what():  /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.
Aborted

我也试过了

eval 'dbus-launch --auto-syntax' ./client

eval 'dbus-launch --auto-syntax' ./server

但它不起作用,服务器应用程序正在启动消息守护程序,但无法从客户端访问。守护进程也保持活动状态。

我明白了:

terminate called after throwing an instance of 'DBus::Error'
  what():  The name org.freedesktop.DBus.Examples.Echo was not provided by any .service files
call1: Aborted

它也没有显示在服务列表中。

在此之后我尝试了另一个命令

DISPLAY=":0" DBUS_SESSION_BUS_ADDRESS="unix:path=/run/dbus/system_bus_socket" ./server

我得到了:

terminate called after throwing an instance of 'DBus::Error'
  what():  Connection ":1.10" is not allowed to own the service "org.freedesktop.DBus.Examples.Echo" due to security policies in the configuration file
Aborted

:( 之后也无法正常工作,我找到了一种无需 X11 代码即可编译 dbus 的方法 与

./configure --with-x=no

不幸的是,它没有效果。仍然需要 X11 来启动我的应用程序... 我怎么了?

但是类似的命令

eval 'dbus-launch --auto-syntax' dbus-monitor

如何在不启动 X11 的情况下启动我的应用程序,我不需要它,我也不想要它。 感谢您的帮助和时间。

亲切的问候 呜呜

#

更新 我现在觉得有点傻,但我找到了一种不用 x11 来运行它的方法

首先你需要启动一个 dbus 会话守护进程

dbus-launch

这将提示您您的 DBUS_SESSION_BUS_ADRESS

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357
DBUS_SESSION_BUS_PID=2465

之后,您可以像这样启动您的 c++ 应用程序

DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-9rMVHdByuH,guid=10592ff7107f13dd241a02af531ab357" ./server

你可以注册服务

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6aT4DZgmA1,guid=b1231a014a7b10e74e04f8ba531abdf9 dbus-send --session --dest=org.freedesktop.DBus   --type=method_call --print-reply                 /org/freedesktop/DBus org.freedesktop.DBus.ListNames

和监控消息

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-6aT4DZgmA1,guid=b1231a014a7b10e74e04f8ba531abdf9 dbus-monitor

还有一个问题,如何自动完成?

【问题讨论】:

  • 抱歉,帖子太长了:)
  • 你好,Dogan,我在你的页面上结束了,因为我在树莓派上遇到了类似的问题。在树莓派上找不到 dbus-launch 命令,我有一个没有 X 服务器的 pi 无头安装。如何获取 dbus-launch 包??

标签: linux shell x11 dbus raspbian


【解决方案1】:

很棒的帖子。你显然比我勤奋;我最终改为运行显示缓冲区。

还有一个问题,我怎么能自动完成呢?

自从

$dbus-launch 

将总线信息输出到标准输出,您是否尝试过运行程序?比如

$dbus-launch ./server

dbus-launch 手册页说:

您可以指定要运行的程序;在这种情况下,dbus-launch 将 启动会话总线实例,设置适当的环境 变量,以便指定的程序可以找到总线,然后 使用指定的参数执行指定的程序。看 下面的例子。

如果你启动一个程序,dbus-launch 不会打印信息 关于标准输出的新总线。

【讨论】:

    【解决方案2】:

    还有一个问题,如何自动完成?

    看看dbus-launch manual

    反引号或 $() 构造可用于从 dbus 启动

    【讨论】:

      猜你喜欢
      • 2011-01-09
      • 1970-01-01
      • 2011-07-28
      • 2012-01-23
      • 2013-12-28
      • 2019-08-03
      • 2020-09-04
      • 2023-03-30
      • 1970-01-01
      相关资源
      最近更新 更多