Reputation: 2315
I have a gtk program in which I am calling a gdk function. I am compiling the program using:
gcc `pkg-config --cflags --libs gtk+-2.0 cairo glib-2.0` ...
and I have included
#include <gdk/gdk.h>
it gives me the error:
undefined reference to `gdk_device_ungrab'
Does anyone know what I am doing wrong?
Upvotes: 2
Views: 904
Reputation: 5423
You are compiling and linking against gtk 2.x and gdk_device_ungrab
is available only starting from gtk 3.0.
See: http://developer.gnome.org/gdk3/3.4/GdkDevice.html#gdk-device-ungrab
Upvotes: 5
Reputation: 2026
You have to put your source or object files before the libraries in the command line, i.e. at the beginning, before the pkg-config part.
The linker adds objects and libraries in the order they are specified in the command line; if the gdk library is listed before your source file, the linker doesn't know your code needs the libray until it is too late.
Upvotes: -1