【发布时间】: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。