I am trying to compile a C program with these headers: http://pastebin.com/SppCXb0U , on Ubuntu. At first I was not lucky at all, but after reading pkg-config I created this line:
gcc `pkg-config --cflags --libs dbus-1` `pkg-config --cflags --libs glib-2.0` signals-tutorial.c
However, it still does not work and gives me this error:
/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
I'm not sure what to do next.
====================================
Good explanation - thanks. However, I cannot get it to work. Running your command above (with the addition) gives the following result
gcc `pkg-config --cflags dbus-1` \ > `pkg-config --cflags glib-2.0` \ > signals-tutorial.c \ > `pkg-config --libs dbus-1` \ > `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
source share