简体   繁体   English

找不到GDK功能

[英]GDK function not found

I have a gtk program in which I am calling a gdk function. 我有一个gtk程序,其中正在调用gdk函数。 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. 您正在编译并针对gtk 2.x进行链接,并且gdk_device_ungrab仅从gtk 3.0开始可用。

See: http://developer.gnome.org/gdk3/3.4/GdkDevice.html#gdk-device-ungrab 请参阅: 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. 您必须将源文件或目标文件放在命令行中的库之前 ,即放在pkg-config部分的开头。

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. 如果gdk库在源文件之前列出,则链接器直到为时已晚才知道您的代码需要libray。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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