title: Compiling C program with dbus header files
body: <p>I'm trying to compile a C program, with these headers: <a href="http://pastebin.com/SppCXb0U" rel="noreferrer">http://pastebin.com/SppCXb0U</a> , on Ubuntu. At first I didn't have any luck at all, but after reading about pkg-config I crafted this line:</p>
  
  <pre><code>gcc `pkg-config --cflags --libs dbus-1` `pkg-config --cflags --libs glib-2.0` signals-tutorial.c
  </code></pre>
  
  <p>However, it still doesn't work and gives me this error:</p>
  
  <pre><code>/tmp/cc3BkbdA.o: In function `filter_example':
  signals-tutorial.c:(.text+0x1a3): undefined reference to `dbus_connection_setup_with_g_main'
  /tmp/cc3BkbdA.o: In function `proxy_example':
  signals-tutorial.c:(.text+0x29a): undefined reference to `g_type_init'
  signals-tutorial.c:(.text+0x2b3): undefined reference to `dbus_g_bus_get'
  signals-tutorial.c:(.text+0x323): undefined reference to `dbus_g_proxy_new_for_name'
  signals-tutorial.c:(.text+0x369): undefined reference to `dbus_g_proxy_add_signal'
  signals-tutorial.c:(.text+0x38a): undefined reference to `dbus_g_proxy_connect_signal'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I'm not sure what to do from here.</p>
  
  <p>==================================</p>
  
  <p>A nice explanation - thank you. However, I can't get it working. Running your command above (with an added ) yield the following result</p>
  
  <pre><code>gcc `pkg-config --cflags dbus-1` \
  &gt;     `pkg-config --cflags glib-2.0` \
  &gt;     signals-tutorial.c \
  &gt;     `pkg-config --libs dbus-1` \
  &gt;     `pkg-config --libs glib-2.0`
  /tmp/ccjN0QMh.o: In function `filter_example':
  signals-tutorial.c:(.text+0x1a3): undefined reference to `dbus_connection_setup_with_g_main'
  /tmp/ccjN0QMh.o: In function `proxy_example':
  signals-tutorial.c:(.text+0x29a): undefined reference to `g_type_init'
  signals-tutorial.c:(.text+0x2b3): undefined reference to `dbus_g_bus_get'
  signals-tutorial.c:(.text+0x323): undefined reference to `dbus_g_proxy_new_for_name'
  signals-tutorial.c:(.text+0x369): undefined reference to `dbus_g_proxy_add_signal'
  signals-tutorial.c:(.text+0x38a): undefined reference to `dbus_g_proxy_connect_signal'
  collect2: ld returned 1 exit status
  </code></pre>