我目前正在 vala 开展一个项目,但无法编译该项目。文件通过valac,很好,但后来我得到这个错误:
C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x437): undefined reference to
gtk_source_view_new' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x48a): undefined reference to
gtk_source_view_set_auto_indent' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD. o:EditorWindow.vala.c:(.text+0x4a2): 未定义引用gtk_source_view_set_indent_on_tab' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4ba): undefined reference to
gtk_source_view_set_show_line_numbers' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4d2):未定义引用gtk_source_view_set_highlight_current_line' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4ea): undefined reference to
gtk_source_view_set_insert_spaces_instead_of_tabs' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0xf74): 未定义引用 `gtk_source_view_get_type'
失败的文件的代码如下:
using Gtk;
using Gtk.Stock;
using Gdk;
public class EditorWindow : GLib.Object
{
public Gtk.SourceView EditorWindow {get;set;}
public HBox TabHeader {get;set;}
private Gtk.Image icon {get;set;}
private Label name {get;set;}
private Button closeButton {get;set;}
public unowned Notebook parent {get;set;}
public EditorWindow(File? file = null, Notebook parent)
{
//Interperet file data
if(file == null)
{
this.name = new Label("testPage.cs");
}
else
{
//get all necessary file data
}
this.TabHeader = new HBox(false, 0);
//this.name = new Label("testPage.cs");
this.closeButton = new Button();
this.closeButton.set_relief(ReliefStyle.NONE);
this.closeButton.set_focus_on_click(false);
this.closeButton.add(new Gtk.Image.from_stock(Gtk.Stock.CLOSE, IconSize.MENU));
this.icon = new Gtk.Image.from_stock(Gtk.Stock.FILE, IconSize.MENU);
this.TabHeader.pack_start(this.icon, false, false, 0);
this.TabHeader.pack_start(this.name, true, true, 0);
this.TabHeader.pack_start(this.closeButton, false, false, 0);
this.EditorWindow = new Gtk.SourceView();
this.EditorWindow.auto_indent = true;
this.EditorWindow.indent_on_tab = true;
this.EditorWindow.show_line_numbers = true;
this.EditorWindow.highlight_current_line = true;
this.EditorWindow.insert_spaces_instead_of_tabs = false;
//parent.append_page(this.EditorWindow, this.TabHeader);
//Read libraries to register objects and methods
//Parse all lines and provide labels
}
public void ParseLibraries()
{
}
public void ParseLocalFiles()
{
}
public void ParseProjectFiles()
{
}
}
该文件在这五行之后失败并显示collect2: ld returne 1 exit status
.
知道如何解决这个问题吗?任何帮助将不胜感激。
编辑
我使用的命令行编译是:valac Main.vala GUI.vala EditorWindow.vala -o Valarian.exe --enable-checking --pkg gtk+-2.0 --pkg gdk-2.0 --pkg gtksourceview-2.0 --thread
. 我在 Windows 上运行它,所以我使用的是 gtk/gdk/sourceview 2.0。