Closed goluckyryan closed 1 year ago
Thank you for the post, Ryan.
Ubuntu 22.04 has GLib-2.0 version 2.72. G_APPLICATION_DEFAULT_FLAGS is a new flag since GLib-2.0 version 2.74. So, the system issued an error.
In that case, there are two solutions.
Please try one of them. Thank you again, and feel free to post issues. Any question is welcome.
Toshio Sekiya
The solution above is written in the section 3. So, this issue is closed.
Hi Toshio,
My system is ubuntu22.04. I installed libgtk-4-dev.
And I copy the code for a blank window and save it to test.cpp
include <gtk/gtk.h>
static void activate (GtkApplication app, gpointer user_data){ GtkWidget window;
window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "Window"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); gtk_widget_show (window); }
int main (int argc, char **argv){ int status;
GtkApplication * app = gtk_application_new ("org.gtk.example", 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; }
compile with g++
pkg-config --cflags gtk4
-o test test.cpppkg-config --libs gtk4
I got an error say:
error: ‘G_APPLICATION_DEFAULT_FLAGS’ was not declared in this scope; did you mean ‘G_APPLICATION_GET_CLASS’? 17 | GtkApplication * app = gtk_application_new ("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS); | ^
~~~~~~ | G_APPLICATION_GET_CLASSI am sorry to brother you with this. but I cannot google the solution. Please help.
Best regards, Ryan