dbus/Qt移植arm:No such signal ::DeviceAdded(QString) 和 system_bus_socket不存在 解决

qt利用dbus检测U盘程序交叉编译无误后,拷贝到板子里,运行报错:

"?????????QDBusInterface?" "Failed to connect to socket /usr/local/arm/dbus-1.0.
2/var/run/dbus/system_bus_socket: No such file or directory"
Object::connect: No such signal QDBusAbstractInterface::DeviceAdded(QString)
Object::connect: (receiver name: 'Widget')
Object::connect: No such signal QDBusAbstractInterface::DeviceRemoved(QString)
Object::connect: (receiver name: 'Widget')

我们看最上面一句是说找不到system_bus_socket这个文件,板子上确实没有,在上篇文章里说过, 我只拷了dbus的那三个库。于是我把PC上整个dbus-1.0.2的库都拷到板子上,可是奇怪的是我在pc上按上面的路径,发现dbus目录下为空,根本没有生成system-bus_socket.怎么回事?这说明我们交叉编译安装的时候,出问题了!nnd,只有重新交叉编译安装了:

1,

./configure --host=arm-linux --prefix=/root/bluez_install/dbus-1.0.2 CC=arm-linux-gcc --cache-file=arm-linux.cache --without-x
如果后面不加--without-x在make的时候会报错:
dbus-launch.c: In function 'kill_bus_when_session_ends':

dbus-launch.c:413:7: error: impossible constraint in 'asm' dbus-launch.c:414:7: error: impossible constraint in 'asm' make[2]: *** [dbus-launch.o] 错误 1 make[2]: 离开目录“/home/yan/download/dbus-1.0.2/tools” make[1]: *** [all-recursive] 错误 1 make[1]: 离开目录“/home/yan/download/dbus-1.0.2” make: *** [all] 错误 2

解决:原来./configure 一定要加"--with-x=no

2,./configure过程中报错:

checking abstract socket namespace... configure: error: cannot run test program while cross compiling

解决:echo ac_cv_have_abstract_sockets=yes>arm-linux.cache
export PKG_CONFIG_PATH=/usr/lib/pkgconfig

3,make时候报错:

make[3]: *** [dbus-sysdeps-unix.lo] 错误 1
make[3]:正在离开目录 `/root/桌面/Qt/bluez源/dbus-1.0.2/dbus'
make[2]: *** [all] 错误 2make[2]:正在离开目录 `/root/桌面/Qt/bluez源/dbus-1.0.2/dbus'
make[1]: *** [all-recursive] 错误 1
make[1]:正在离开目录 `/root/桌面/Qt/bluez源/dbus-1.0.2'make: *** [all] 错误 2
解决办法:打开dbus/dbus-sysdeps-unix.c
添加:
struct ucred
{
pid_t pid; /* PID of sending process. */
uid_t uid; /* UID of sending process. */
gid_t gid; /* GID of sending process. */
};
经过三个步骤交叉编译出dbus后,打开
/usr/local/arm/dbus-1.0.
2/var/run/dbus/

竟然还是找不到system_bus_socket, NND,真恼火,究竟是咋回事??????????????????????????

原来是需要运行:dbus-daemon --system,这个时候var/run/dbus下面还是什么也没有,但是在终端里(pc上的,现在还没到移植到arm)用ls命令一查看,发现var/run文件夹下很多东西,原来这个文件夹下的东西是隐藏。在看dbus下面也有sysytem_bus_socket这个文件了!下面就打包移植!

它奶奶的,弄到板子上错误依旧!而且我发现,pc上var/run/dbus下面即便用命令ls查看也什么都没有了!万念俱灰啊!

痛定思痛,仔细阅读了几乎google的所有文章,有用的有几篇:

http://note.sdo.com/u/422029744/n/p9WCM~jXIebOwE04g005D3

http://blog.chinaunix.net/space.php?uid=21931055&do=blog&id=328769

http://hi.baidu.com/lihuanhai1943/blog/item/00ef57faf02907dab58f3113.html

这才知道dbus-1.0.2文件下的bin文件是有作用的,dbus拷贝到板子上后是需要配置的。dbus下的bin里面的dbus-daemon是个很关键的东西,貌似必须用他来启动dbus。

那就切换到bin下运行:./dbus-daemon --system.

报错如下:

Failed to start message bus: Could not get UID and GID for username "messagebus

这时我试了下adduser这个命令,竟然可以用在我的Tiny210开发板上!那就赶紧:[root@FriendlyARM bin]# adduser messagebus

会提示出入密码.密码设好后,再次运行./dbus-daemon --system竟然没有报错,去查看下system_bus_socket也存在了!这可是在板子上哦,不容易啊!

dbus/Qt移植arm:No such signal ::DeviceAdded(QString) 和 system_bus_socket不存在 解决_第1张图片

接着运行我的qt检测U盘程序,这次继续报错,只不过错误不一样了:

"?????????QDBusInterface?" "The name org.freedesktop.Hal was not provided by any
.service files"
Object::connect: No such signal QDBusAbstractInterface::DeviceAdded(QString)
Object::connect: (receiver name: 'Widget')
Object::connect: No such signal QDBusAbstractInterface::DeviceRemoved(QString)
Object::connect: (receiver name: 'Widget')

一个小小的qt检测U盘插拔竟让我费了这么大劲,不知道网上那些寥寥数语就实现此功能的神人,怎么弄出来的。欲知后事如何下回分解把。洒家再研究吧。





你可能感兴趣的:(socket)