Linux: Build D-Bus examples

In my pursuit of learning about d-bus, I realized I have no idea how to compile it. Not sure why but the books and blogs that give examples don’t give instructions to build it. I’ll fill in that vacuum.

I’m reading the Professional Linux Programming which you can download the sample code here. It’s the example code for Ch 12. FreeDesktop.

Here is how to build it:

gcc $(pkg-config --cflags dbus-1 glib-2.0) -o get-hello dbus-get-hello.c $(pkg-config --libs dbus-1 glib-2.0)

gcc $(pkg-config --cflags dbus-1 glib-2.0) -o send-hello dbus-send-hello.c $(pkg-config --libs dbus-1 glib-2.0)

In Terminal 1:

Received TestSignal with value of: ‘Hello World’ (After send-hello executes this line will print out)

In Terminal 2:

Sending signal to D-Bus

Required libs:

sudo apt-get install libdbus-glib-1-dev dbus-1


If you’re seeing the error:

error: dbus/dbus-glib.h: No such file or directory

You don’t have the package libdbus-glib-1-dev installed


Can’t figure out how to build the hal-optical-test or halloworld files.

Not sure how to link the hal library. I can’t even find the hal libs on the file system.

Error: libhal.h:  No such file or directory

This entry was posted in Linux and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s