Button.vala #include <gtk/gtk.h> errors:

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
vmars316
Posts: 62
Joined: Thu 26 Apr 2012, 18:50
Location: Brownsville, Texas, USA

Button.vala #include <gtk/gtk.h> errors:

#1 Post by vmars316 »

Greetings,
I am unable to find a good windows/vala/genie
Forum. So, thought i'd try here:

I am getting two errors, apparently from the #include.
The gtk.h is here:
C:\vala-0.12\Vala\vala-win32\vala-win32\gtk-bin\include\gtk-2.0\gtk
How do i tell valac where gtk.h is?
Pls, where does the #include belong.(see source below)
Thanks...Vernon

C:\vala-0.12\vmVala>valac -o Button Button.vala
Button.vala:2.2-2.9: error: syntax error, invalid preprocessing directive
#include <gtk/gtk.h>
^^^^^^^^
Button.vala:2.10-2.10: error: syntax error, expected identifier
#include <gtk/gtk.h>
^
Compilation failed: 2 error(s), 0 warning(s)
=======================

// C:\vala-0.12\Vala\vala-win32\vala-win32\gtk-bin\include\gtk-2.0\gtk
#include <gtk/gtk.h>
using Gtk;

public void on_button_clicked(Button source)
{
stdout.printf("Button clicked\n");
}

int main(string[] args)
{
Gtk.init(ref args);

var window = new Window();
window.destroy.connect(Gtk.main_quit);

var button = new Button.with_label("Button");
button.clicked.connect(on_button_clicked);
window.add(button);

window.show_all();

Gtk.main();
return 0;
}

User avatar
darkcity
Posts: 2534
Joined: Sun 23 May 2010, 19:16
Location: near here
Contact:

#2 Post by darkcity »

Welcome,

are you compiling on Windows or Linux under WINE?

It may be worth asking specific questions on the programming sub forum
http://www.murga-linux.com/puppy/index.php?f=46

:twisted:

User avatar
Mobeus
Posts: 94
Joined: Thu 26 Aug 2010, 15:49

#3 Post by Mobeus »

Vala is not the same as C, the GTK headers are included with the statement ‘using GTK;’ and then compiling with ‘valac --pkg gtk+-2.0 yourfile.vala’ so you do not #include <gtk/gtk.h>

Look at the examples here https://live.gnome.org/Vala/GTKSample

Code: Select all

using Gtk;

public void on_button_clicked(Button source){
    stdout.printf("Button clicked\n");
}

int main(string[] args){
    Gtk.init(ref args);

    var window = new Window();
    window.destroy.connect(Gtk.main_quit);

    var button = new Button.with_label("Button");
    button.clicked.connect(on_button_clicked);
    window.add(button);

    window.show_all();

    Gtk.main();
    return 0;
}
 
save as test.vala and compile with valac --pkg gtk+-2.0 test.vala
/root for the home team

User avatar
vmars316
Posts: 62
Joined: Thu 26 Apr 2012, 18:50
Location: Brownsville, Texas, USA

#4 Post by vmars316 »

darkcity wrote:Welcome,
are you compiling on Windows or Linux under WINE?
:twisted:
I am compiling under Windows7.

Yes, will do:
http://www.murga-linux.com/puppy/index.php?f=46

...vm

Post Reply