【问题标题】:Vala - fatal error: gtk/gtk.h - thrown error using Gtk libsVala - 致命错误:gtk/gtk.h - 使用 Gtk 库引发的错误
【发布时间】:2013-12-18 18:08:53
【问题描述】:

Vala 中的源代码:

using GLib;
using Gtk;

class MainWindow : Window  {

  public static int main (string[] args) 
  {    
    var window = new MainWindow();
    window.destroy.connect(Gtk.main_quit);
    window.show_all();

    Gtk.main();

    return 0;
  }

  public MainWindow()
  {
    this.title = "Title";
    this.set_default_size(400, 450);
    this.border_width = 10;

    this.window_position = WindowPosition.CENTER;
    this.destroy.connect(Gtk.main_quit);

    var btnClear = new Button.with_label("Button");
    add(btnClear);
  }
}

在 Ubuntu 13.10 上编译时出现错误:

user@dev:/path$ valac --pkg gtk+-3.0 "dev.vala" -o dev
/path/dev.vala.c:7:21: fatal error: gtk/gtk.h: No such file or directory
 #include <gtk/gtk.h>
                     ^
compilation terminated.
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

所以,Ubuntu 使用 Gtk3。我已经强制使用 gtk3.0 并确保安装了 libgtk3 的库。

第二个问题,如果我想开发 Gtk 2.0,如果只支持 Gtk 3,我该如何在 Ubuntu 上做?

【问题讨论】:

  • Gtk+ 2.0 应用程序应该可以在 Ubuntu 上正常运行,您从哪里知道它们不能运行?很多 Gtk+ 应用程序仍然使用 2.0
  • 因为我在 Ubuntu 上使用终端和编译 Vala 时遇到了几个错误。我在两个版本上都有错误。您需要安装 libgtk2-dev 以便从 gtk2 库进行编译。也许是因为我使用的是 Xubuntu 而不是 Ubuntu。

标签: ubuntu gtk vala


【解决方案1】:

您也必须安装 libgtk-3-dev 软件包。

基于 Debian 和 Ubuntu 的发行版中的 -dev 后缀包包含开发所需的文件。

另外还有一个libgtk2-dev 包,用于在 Ubuntu 中开发 Gtk+ 2.0 应用程序。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2010-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-21
  • 1970-01-01
  • 1970-01-01
  • 2016-08-10
相关资源
最近更新 更多