1

I'm trying to create a simple GUI application with Vala to demonstrate running a basic application which shows a Gtk.Window. (I'm running Fedora 25 with up to date packages if it helps at all)

My window.vala file looks like this:

using GLib;
using Gtk;

class MWindow : Window {
    public MWindow(){
        //this.type = WindowType.TOPLEVEL;
        this.border_width = 12;
        this.destroy.connect(Gtk.main_quit);

        Button btn = new Button.with_label("Click");
        btn.clicked.connect(() => {
            btn.label = "clicked already";
        });

        this.add(btn);
        this.show_all();
    }

    public static int main(string[] args){
        MWindow mwin = new MWindow();
        Gtk.main();
        return 0;
    }
}

I'm compiling it like this:

valac --pkg gtk+-3.0 window.vala

I receive this error:

window.vala.c:7:21: fatal error: gtk/gtk.h: No such file or directory
 #include <gtk/gtk.h>
                     ^
compilation terminated.

I can't understand what is wrong because I have gtk+-devel and gtk3-devel installed as well as gtk+ and gtk3 installed. Is there something simple I'm missing? (I looked at this Stack Overflow question, but it isn't applicable to this problem).

Community
  • 1
  • 1
KG6ZVP
  • 3,610
  • 4
  • 26
  • 45
  • What is the output of `pkg-config --cflags gtk+-3.0` on your system? – Jens Mühlenhoff May 11 '17 at 10:29
  • Seems like the files were not installed on the correct location. Btw, you must add Gtk.init (ref args) rigth after the main declaration and the MWindow creation otherwise your code won't run. 73 ;) – José Fonte May 11 '17 at 14:04
  • @JensMühlenhoff: I got the output "Package x11 was not found in the pkg-config search path. Perhaps you should add the directory containing `x11.pc' to the PKG_CONFIG_PATH environment variable Package 'x11', required by 'egl', not found", so I installed libX11-devel.x86_64 – KG6ZVP May 11 '17 at 20:28
  • Possible duplicate of [gtk+-3.0 not found issue](http://stackoverflow.com/questions/38050294/gtk-3-0-not-found-issue) – Jens Mühlenhoff May 20 '17 at 08:25
  • It isn't a duplicate of gtk+-3.0 not found because the package was clearly installed, but it might be good to link them anyway for others searching. – KG6ZVP May 21 '17 at 23:24

1 Answers1

1

The solution, as pointed out by Jens Mühlenhoff, was to run:

pkg-config --cflags gtk+3.0

and check it's output, which gave an error about X11 missing.

I had libX11-devel.i686, but not libX11-devel.x86_64, so I installed that package and the build worked.

KG6ZVP
  • 3,610
  • 4
  • 26
  • 45