Gtk+ 3.0 中的 GtkGlArea:未定义的引用

GtkGlArea in Gtk+ 3.0: undefined reference

GtkGlArea 已在 the Widget Gallery of Gtk+3.0. There is official documentation 中列出,说明我只需包含 gtk/gtk.h 即可使用所需的小部件。

但我在gtk+-3.0 包的头文件中找不到任何OpenGl 提及。当然,我无法在不遇到 undefined reference 错误的情况下调用任何 gtk_gl_area_* 函数。

GtkGlArea 在 Gtk+ 3.0 中不可用吗?如果有,为什么会出现在官网?

如果可用,我如何在我的 C 项目中使用它?

GTK+ 3.16 添加了 GtkGLArea。如果你看the documentation page for GtkGLArea,你会看到

Since: 3.16

gtk_gl_area_new() 之下。

如果您是 运行 GTK+ 3.14 或更低版本,则您无权访问 GtkGLArea。您的发行版可以告诉您安装了哪个版本。如果您的发行版确实提供了更新的版本,那么您将需要安装它。 (撰写本文时的当前版本是 GTK+ 3.18。)

如果您没有 GTK+ 3.16 或更高版本,并且需要继续使用您使用的发行版,您有几个选择:

  • 找别人的OpenGL widget; here's one and here's another
  • 使用jhbuild安装更新的GTK+版本的本地版本并使用它来开发
  • 使用具有较新发行版的虚拟机进行开发

编辑:您还可以通过从 this list. (The same applies to the other documentation sets on developer.gnome.org.) If backward compatibility is your thing, you should also look into the GDK_VERSION_MIN_REQUIRED and GDK_VERSION_MAX_ALLOWED macros.

中选择一个版本来查看您需要定位的特定 GTK+ 版本的文档