"undefined reference to `gtk_label_set_xalign'" 编译 Vala 应用程序时

"undefined reference to `gtk_label_set_xalign'" when compiling a Vala application

我正在编写 Vala 应用程序并在其中使用标签。这是构造函数(我猜这是导致错误的地方):

titleLabel = new Gtk.Label("");
titleLabel.set_markup(wrapInTags(post.title));
titleLabel.set_line_wrap(true);
titleLabel.wrap_mode = Pango.WrapMode.WORD_CHAR;
titleLabel.set_justify(Gtk.Justification.LEFT);
//titleLabel.set_max_width_chars(40);
titleLabel.set_xalign(0);

当我编译它时,会发生这种情况:

CMakeFiles/photostream.dir/Widgets/PostBox.c.o: In function `photo_stream_widgets_post_box_construct':
PostBox.c:(.text+0x2111): undefined reference to `gtk_label_set_xalign'
CMakeFiles/photostream.dir/Widgets/CommentsBox.c.o: In function `photo_stream_widgets_comment_box_construct':
CommentsBox.c:(.text+0x1045): undefined reference to `gtk_label_set_xalign'
CMakeFiles/photostream.dir/Widgets/NewsBox.c.o: In function `photo_stream_widgets_news_box_construct':
NewsBox.c:(.text+0x1af8): undefined reference to `gtk_label_set_xalign'
CMakeFiles/photostream.dir/Windows/BulkDownloadWindow.c.o: In function `photo_stream_bulk_download_window_construct':
BulkDownloadWindow.c:(.text+0x14b1): undefined reference to `gtk_label_set_xalign'
collect2: error: ld returned 1 exit status

我尝试用 titleLabel.xalign = 0 替换最后一个字符串,但结果还是一样。

我该如何解决?

看来我找到了答案,据此:https://developer.gnome.org/gtk3/stable/GtkLabel.html gtk_label_set_xalign() 方法从 GTK+ 3.16 开始可用,我使用的是 3.14。