Issue
I am trying to build a simple WebKit example. After first trying to use an older version, I am stuck upgrading to webkitgtk-6.0.
My code is as following:
// cc `pkg-config --cflags --libs webkitgtk-6.0 ` WebKitTest2.c
#include <gtk/gtk.h>
#include <webkit/webkit.h>
void
activate (GtkApplication *app, gpointer)
{
GtkWidget *window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), "NPC");
gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
GtkWidget *webView = webkit_web_view_new ();
gtk_window_set_child (GTK_WINDOW (window), webView);
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (webView),
"https:/google.com");
gtk_widget_show(window);
gtk_window_present (GTK_WINDOW(window));
}
int
main (int argc, char *argv[])
{
int status;
GtkApplication *app = gtk_application_new ("com.example.GtkApplication",
G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
status = g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return status;
}
results in:
$ ./WebKitTest
libEGL warning: MESA-LOADER: failed to open vgem: /usr/lib/dri/vgem_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libEGL warning: failed to open /dev/dri/card0: Permission denied
(process:2): Gdk-WARNING **: 14:30:13.944: Settings portal not found: Failed to execute child process “dbus-launch” (No such file or directory)
libEGL warning: MESA-LOADER: failed to open vgem: /usr/lib/dri/vgem_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libEGL warning: failed to open /dev/dri/card0: Permission denied
^C
Any ideas? I am using debian WSL. No window pops up, but I do see a taskbar icon. If I click on that icon, nothing happens.
This was the older sample that worked fine:
//clang `pkg-config --cflags --libs webkit2gtk-4.1` WebKitTest.c++
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
static void
destroyWindowCb (GtkWidget *widget, GtkWidget *window)
{
gtk_main_quit ();
}
int
main (int argc, char *argv[])
{
gtk_init (&argc, &argv);
GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
WebKitWebView *webView = WEBKIT_WEB_VIEW (webkit_web_view_new ());
gtk_container_add (GTK_CONTAINER (main_window), GTK_WIDGET (webView));
g_signal_connect (main_window, "destroy", G_CALLBACK (destroyWindowCb),
NULL);
webkit_web_view_load_uri (webView, "https://google.us");
gtk_widget_show_all (main_window);
gtk_main ();
return 0;
}
EDIT: I also tried that under Ubuntu WSL, same error :(
Solution
Well, turns out the problem ceases to exist when using a real virtual machine and not WSL :)
Answered By - johnworchester Answer Checked By - Gilberto Lyons (WPSolving Admin)