Getting started with VALA

Estimated reading time: 3 minutes
While browsing and looking for news in the open source world, I came to find about VALA.  A ‘new’ programming language created to design and implement applications for GNOME. VALA has built-in features GObject, GLib,… VALA is translated into C code and apparently it is very efficient C code (benchmarks) So I wanted to dive into VALA and find out more about it…Documentation and blog posts about VALA are rare, except for the official language description page, and even though the people seems to be very active on the project (Version 0.8.0 released in March 2010) the information on it is limited. The standard documentation is rather good online and on the site of VALA may information can be found, however as soon as something goes wrong no information is available. So I want to describe here my experience setting up the environment to compile and run my first VALA program.
I prepared my Ubuntu environment with the following packages
user@computer:$ sudo apt-get install flex lex bison yacc glib gobject-introspection libglib2.0-dev
You could install the version of VALA from the Ubuntu repositories, but the version for Karmic is 0.7.6 and apparently this version contains some bugs.
Rather download the latest version of VALA from here, the version I have been using is version 0.8.0. To install VALA you need to use the standard method, extract the files to a folder, open terminal in that folder and then use first,
user@computer:$ ./configure
, second,
user@computer:$ make
and last,
user@computer:$ make install.
So I tried the Hello World example (from here):
using GLib;

public class Sample : Object {
public Sample () {

public void run () {
stdout.printf ("Hello, world!\n");

static int main (string[] args) {
var sample = new Sample (); ();
return 0;
However trying to compile it, I get the following error message
user@computer:$ valac -o hello hello.c
valac: error while loading shared libraries: cannot open shared object file: No such file or directory
Clearly the compiler could not find the libraries, however they were exactly where they were supposed to be, namely in the directory /usr/local/lib. To correct the error at compiling time, I had to run the command
user@computer:$ sudo ldconfig
to update the linkers to dynamic libraries.
I use gEdit together with Valencia plugin to write VALA code and I also want to try out the Vala Toys for gEdit. However with the latest version of VALA (0.8.0) the current version of Valencia 0.2.1 is not compatible with version 0.8.0. You need to check out the latest version from the development trunk of valencia via Subversion, where additional information on the plugin is available.
After that the hello world compiled just fine. I am curious to see where VALA is taking me. Many bindings exists for GTK+, Cairo, Clutter, GNOME,….

Valencia AutoComplete

Go To Definition of a Method or Class


  1. says


  2. says

    Here is the updated steps for the new version of Vala.for the prep:sudo apt-get install flex bison gobject-introspection libglib2.0-dev

  3. Armen says

    Here is the updated steps for the new version of Vala.

    for the prep:

    sudo apt-get install flex bison gobject-introspection libglib2.0-dev

    everything else the same-

    the sample code should be updated as follows:



    class Demo.HelloWorld : GLib.Object {

    public static int main(string[] args) {

    stdout.printf("Hello, World

    return 0;



    to compile and run:

    $ valac hello.vala

    $ ./hello

  4. Armen says

    Thx for the tutorial,

    the first step though didn't work on my machine (ubuntu 9.10)

    user@computer:$ sudo apt-get install flex lex bison yacc glib gobject-introspection libglib2.0-dev

    saying flex, yacc and glib packages does not exist.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre user="" computer="" escaped="">