简体   繁体   中英

GDK function not found

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?

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

You have to put your source or object files before the libraries in the command line, ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM