tags:

views:

103

answers:

1

I've been playing with GLib's D-Bus bindings, trying to get something (anything) working, with very limited success. I've been trying to get Ross Burton's example code to compile and run, but keep hitting new and exciting difficulties.

Can you help debug this code, or failing that, point me at some example of D-Bus GLib code that does work?

Since Ross' code is out-of-date, I've replaced the line

dbus_g_object_class_install_info (G_OBJECT_CLASS (echo_class), &dbus_glib_echo_object_info);

with

dbus_g_object_type_install_info (G_OBJECT_TYPE (echo_class), &dbus_glib_echo_object_info);

per his comments on that article, but made no other changes other than to update the include directories to match the setup on my box.

When running the server executable, though, I get the following error:

** (process:11747): CRITICAL **: dbus_g_object_type_install_info: assertion `G_TYPE_IS_CLASSED (object_type) || G_TYPE_IS_INTERFACE (object_type)' failed

The stack trace at this point, according to gdb, is

#0  0x0000003b5f40b440 in dbus_g_object_type_install_info () from /usr/lib64/libdbus-glib-1.so.2
#1  0x0000003b5722909c in g_type_class_ref () from /lib64/libgobject-2.0.so.0
#2  0x0000003b57229798 in g_type_create_instance () from /lib64/libgobject-2.0.so.0
#3  0x0000000000400f16 in main (argc=<value optimized out>, argv=0x7fff156497d8) at EchoObject.c:111

I'm not sure what's going wrong, or what the next steps should be in debugging. I'd like to get some basic code sending and receiving D-Bus method call messages, so I can see how things should work to use in my application.

I'm using D-Bus 0.73.

Update: Given the lack of success on my part, and the lack of response here, I'm currently looking at abandoning D-Bus and finding some other IPC mechanism.

Update 2: In the end, I went with a Unix named sockets approach, which is doing exactly what I need it to do in a total of 280 lines of code (plus test code).

+2  A: 

dbus-glib is pretty ... nasty to use, and it's basically unmaintained at this point. You're probably better off using its upcoming replacement, GDBus, which will be included in the next stable GLib release. Check out the Lowlevel D-Bus support and Highlevel D-Bus support sections of the documentation for more details.

wjt
I've rolled with a different solution now, so I don't think I'll be waiting for GDBus to appear. Thanks anyway!
me_and