Search code examples
javaeclipseswtvalawebkit2

fatal error: webkit2/webkit2.h: No such file or directory


On Arch Linux, after upgrading to Gnome 3.14, I have several troubles with Webkit2Gtk.

Vala: Consider the following vala test:

using Gtk;
using WebKit;

public class ValaWebkit : Window {

    private WebView web_view;

    public ValaWebkit(){
        this.title = "Testing youtube";
        set_default_size (800, 600);

        web_view = new WebView();
        add(web_view);

        //this.web_view.open ("http://www.youtube.com/");
        this.web_view.load_uri ("https://www.youtube.com/");
    }

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

        new ValaWebkit().show_all();
        Gtk.main();

        return 0;
    }
}

Before upgrading to Gnome 3.14, I could copile like this valac --pkg gtk+-3.0 --pkg webkit2gtk-3.0 --vapidir . valawebkit.vala (I'm not pasting here webkit2gtk-3.0.vapi because it's too long). Now with gnome 3.14 if I try to compile i get

/home/luca/Sources/vala/webkit test/valawebkit.vala.c:8:29: fatal error: webkit2/webkit2.h: No such file or directory
 #include <webkit2/webkit2.h>
                             ^
compilation terminated.
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

Also, If I try to run the binary that I had compiled BEFORE upgrading to Gnome 3.14, I get this error:

./valawebkit: error while loading shared libraries: libwebkit2gtk-3.0.so.25: cannot open shared object file: No such file or directory

2) GJS / Eclipse / Java (SWT): If I run either this gjs example, or eclipse (luna) or any other swt 4.4 based app, I get the following:

No bp log location saved, using default.
[000:000] Cpu: 6.58.9, x4, 2600Mhz, 7847MB
[000:000] Computer model: Not available
[000:000] Browser XEmbed support present: 1
[000:000] Browser toolkit is Gtk2.
[000:004] Using Gtk2 toolkit
[000:004] Warning(optionsfile.cc:47): Load: Could not open file, err=2
[000:004] No bp log location saved, using default.

I have the feeling that it is a kind of packaging issue on ArchLinux and Gnome 3.14. Does anyone is having the same issue? Is there a workaround both to compile and run against webkit2gtk?

EDIT I made a little progress: I discovered that headers files I need are now under /usr/include/webkitgtk3.0 and /usr/include/libsoup-2.4. Now, compiling like this:

valac --pkg gtk+-3.0 --pkg webkit2gtk-3.0 --vapidir . --Xcc="-I/usr/include/webkitgtk-3.0" --Xcc "-I/usr/include/libsoup-2.4" --thread valawebkit.vala

works, but it sill fails on linker:

/tmp/ccQGhB3b.o: In function `vala_webkit_construct':
valawebkit.vala.c:(.text+0x6e): undefined reference to `webkit_web_view_new'
valawebkit.vala.c:(.text+0x101): undefined reference to `webkit_web_view_load_uri'
collect2: error: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

Solution

  • Actually with webkit2gtk-4.0 I don't need to provide a vapi file any more. So I can delete my webkit2gtk-4.0.vapi and complile like this (even simpler):

    valac --pkg gtk+-3.0 --pkg webkit2gtk-4.0 --thread valawebkit.vala