Gtk_application_new G_APPLICATION_DEFAULT_FLAGS missing on Windows

Hello, I’m working on a cross-platform C application using GTK 4 and I’m trying to keep my code as simple as possible. Last time I compiled it on Windows (I use Code::Blocks) it went fine, but recently G_APPLICATION_FLAGS_NONE constant that I used on gtk_application_new() became deprecated and as the documentation suggests I replaced it by G_APPLICATION_DEFAULT_FLAGS. On Linux it works fine, but today I tried to compile on Windows (11) and it didn’t knew about G_APPLICATION_DEFAULT_FLAGS. I simply replaced it by its value (0), but do someone know of a way to update GTK to be able to use it ?

You need to update GLib, not GTK. The G_APPLICATION_DEFAULT_FLAGS enumeration value is available since GLib 2.74, released in September 2022.

Thank you. I don’t usually use Windows, but as the application I’m making can be useful to people using Windows, I decided to compile it for this platform even if I’m working on Linux (Ubuntu). At the beginning of my project I simply used Geany and simple portable C code. Sadly my project needs to export vector graphics and the simple library I used wasn’t able to produce rotated text, so I started using GTK for Cairo, and opted for GTK4. But on windows it was too complex for me to keep using Geany to compile, so I started using Code::Blocks that works well both on Linux and Windows. To install GTK libraries on Windows I used a software called “MSys2” by running on its console
pacman -S mingw-w64-x86_64-gtk4

Then on Code::Blocks i only need to use “pkg-config” on compile and link options. I’m not sure how to update GLib using MSys2 and have it reflected on the “pkg-config” files. Can I run Msys2 console and run meson update of Glib2 here ?

Have you tried running pacman -S glib2 (or pacman -Syu) command in MSys2 console?

Thank you for this command. I tried it, apparently it updated GLib2 library, but nothing changes when I compiled with Code::Blocks. I will try your second command that will update all MSys2 installation.

From your commands proposals, I dig msys2 and finally found how to do this update

pacman -S mingw-w64-x86_64-glib2

But then, if my project compiles, at execution I had a run time, saying that a dll was missing, so I reinstalled it, but apparently there’s something else as my code doesn’t run anymore, and its behaviour is odd : it opens a file a first time, then save data, and then it normally opens the same file a second time but this time with the same path fopen returns it’s an invalid argument. And this works fine on Linux and it also worked fine on Windows before, but I haven’t compile on windows since some time and the code changed, so I need to look deeper on my changes, but I’m wondering if I’d better only stay with only my Linux version and stop this Windows version.

I have never tried compiling a GTK app for windows. So, I can’t give any advice on this except that working with two different OSes is bound to bring such issues and complexities. It depends on how much time you have and how much do you want your app to be available on Windows.

Indeed it was not hard, I managed to have only one code that was portable and worked both on Linux and Windows. Main problem I encountered was to deal with file paths, and using g_build_filename() solved it. I also struggle with special characters that we use in french language and that windows didn’t accept, at first I used g_locale_from_utf8() but now I have my main.c encoded in UTF8.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.