Alex Rivera | Logout

How to compile a basic D-Bus/glib example?

Asked 2013-01-10T17:09:28.457
21

I'm trying to learn how to use D-Bus with C bindings. I've never used D-Bus before. I'm following this tutorial, which I assume is the official one (Freedesktop.org). I've read it until this paragraph that gives a first sample program , but unfortunately I don't see any indication on this page about how to compile it or which libraries to include. Did I miss something ?

My OS is Ubuntu 10.04 32bit. I installed the libdbus-glib-1-dev package. I tried to add #include <dbus/dbus.h> at the beginning of the source file, and to compile with

$ gcc -ldbus-1 -I/usr/include/dbus-1.0/ -I/usr/lib/i386-linux-gnu/dbus-1.0/include -o my_dbus.bin my_dbus.c

but I just keep failing:

my_dbus.c: In function ‘main’:
my_dbus.c:7:3: error: unknown type name ‘DBusGConnection’
my_dbus.c:8:3: error: unknown type name ‘GError’
...

Did I miss a point in the tutorial ? It not, could you please help me compile this piece of code ?

Thanks in advance.

Edit
Report

1 Answer

2

Looks like you have to include <dbus/dbus-glib.h> separately, as it is not automatically included by <dbus.h>

answered 2013-01-10T17:15:02.073

Your Answer