Question

I just started with learning vala. I tried the following program from the vala tutorial.

class Demo.Hello : Glib.Object
{
  public static int main( string[] args )
  {
    stdout.printf("Hello, Vala!\n");
    return 0;
  }
}

and got this when I compiled.

$ valac hello.vala 
hello.vala:1.20-1.23: error: The symbol `Glib' could not be found
class Demo.Hello : Glib.Object
                   ^^^^
Compilation failed: 1 error(s), 0 warning(s)
[1]+  Done                    gvim hello.vala

If I remove Glib. from Glib.Object i.e leave it with just class Demo.Hello : Object, then everything works fine. But all the programs in the tutorial use Glib.Object. What's wrong here? I searched for answers but could not find it. Here is the vala version info:

$ valac --version
Vala 0.5.2

And I am running the latest version of CentOS.

Was it helpful?

Solution

The correct name is GLib. But you can just as well leave the "GLib." out and just write "Object", the GLib namespace is implicitely used in all vala apps. For other namespaces you can use "using", for example using Gtk;.

OTHER TIPS

The namespace is called GLib (with big L) not Glib..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top