gccgtkmingwvalagtksourceview

Valac "undefined reference" error with gtksourceview


I am currently working on a project in vala and I am having trouble getting the project to compile. The files pass through valac, just fine but then I get this error:

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 togtk_source_view_set_auto_indent' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4a2): undefined reference to gtk_source_view_set_indent_on_tab' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4ba): undefined reference togtk_source_view_set_show_line_numbers' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4d2): undefined reference to gtk_source_view_set_highlight_current_line' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0x4ea): undefined reference togtk_source_view_set_insert_spaces_instead_of_tabs' C:\Users\Andrew\AppData\Local\Temp/ccEYx9mD.o:EditorWindow.vala.c:(.text+0xf74): undefined reference to `gtk_source_view_get_type'

The code for the file in question that is failing is as follows:

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()
    {

    }
}

The file fails out after those five lines and says collect2: ld returne 1 exit status.

Any idea how to solve this problem? Any help at all would be appreciated.

EDIT

The command line compilation that I used was: 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. I am running this on windows, so I am using gtk/gdk/sourceview 2.0.


Solution

  • I don't like to answer my own question on here, but since we were looking in the wrong direction, here goes:

    The problem that I was experiencing where the compiler was running into 'undefined reference' errors was caused by the manually applied namespace 'Gtk' before SourceView at the top of the EditorWindow class. Due to the nature of the Vala compiler, it did not throw an error because SourceView is under the Gtk namespace, but apparently something went wrong between valac and gcc. As soon as I changed Gtk.SourceView to SourceView, the program compiled.