Hi, i am using vscode and i am trying to test the example in the https://www.gtk.org/
home page.
// Include gtk
#include <gtk/gtk.h>
static void on_activate(GtkApplication *app)
{
// Create a new window
GtkWidget *window = gtk_application_window_new(app);
// Create a new button
GtkWidget *button = gtk_button_new_with_label("Hello, World!");
// When the button is clicked, close the window passed as an argument
g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_window_close), window);
gtk_window_set_child(GTK_WINDOW(window), button);
gtk_window_present(GTK_WINDOW(window));
}
int main(int argc, char *argv[])
{
// Create a new application
GtkApplication *app = gtk_application_new("com.example.GtkApplication",
G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(on_activate), NULL);
return g_application_run(G_APPLICATION(app), argc, argv);
}
Now i am getting an error that i cannot find gtk/gtk.h
So i changed the include to #include <gtk-4.0/gtk/gtk.h>
Note that i have several gtk versions in /usr/include
, i have gtk-2.0
, gtk-3.0
and gtk-4.0
.
Now it asks me for gtk/css/gtkcss.h
so i included it.
#include <gtk-4.0/gtk/css/gtkcss.h>
#include <gtk-4.0/gtk/gtk.h>
Now the compiler asks me for glib.h
gcc -Wall --static -o target/app src/main.c
In file included from src/main.c:2:
/usr/include/gtk-4.0/gtk/css/gtkcss.h:30:10: fatal error: glib.h: No such file or directory
30 | #include <glib.h>
| ^~~~~~~~
compilation terminated.
make: *** [makefile:8: target/app] Error 1
So i included it:
#include <glib-2.0/glib.h>
#include <gtk-4.0/gtk/css/gtkcss.h>
#include <gtk-4.0/gtk/gtk.h>
gcc -Wall --static -o target/app src/main.c
In file included from src/main.c:1:
/usr/include/glib-2.0/glib.h:30:10: fatal error: glib/galloca.h: No such file or directory
30 | #include <glib/galloca.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [makefile:8: target/app] Error 1
This bastard keeps asking for includes, Is there a solution for this ?