[C] [GTK] [Windows 11] [msys2] Trying to produce a working .exe on Windows

My professor has given me the task of creating a GUI for his programming language for use on Windows. Specifically I’m tasked with using GTK and coding it in C. I’m not too worried about the syntax of using GTK, but I’ve had a lot of difficulty in producing a working .exe on windows. Part of this is because I’m a mac user. I’m using a virtual windows machine to try and develop and compile the program so I don’t have to go through the hassle of cross compiling.

In my windows 11 virtual machine, I’m compiling through msys2 using:

gcc hello.c -o hello.exe pkg-config --cflags --libs gtk4

The resulting .exe cannot be simply clicked on and run without a DLL error. So I have to run it from the command prompt after adding system path variables.

From the command prompt, it all works except for keyboard input. I get the Gdk-WARNING “Failed to load keyboard layout DLL”

The only keypress that executes an action is the backspace. None of the letters can be interpreted.

I tried regsvr32 on the specific DLL it calls out, “the module KbdPrlUS.dll was loaded, but the entry-point DllRegisterServices was not found”

This project has not been very straight forward from the jump and I’m just looking for advice on how to get back onto a productive path toward producing a windows .exe

Hello, sorry to hear about those problems!

This keyboard input issue is going to be fixed in the upcoming stable release by https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4986

As for launching the .exe, yes, that should be done from the MSYS2 shell, as it sets the right PATH environment variable. Otherwise you can copy your .exe in C:\msys64\mingw64\bin, that way it will launch correctly with a double click on the .exe from Explorer.

1 Like

Thank you so much for the reply.

Would using GTK3 allow me to bypass the issue? That’s what I’ll be trying to do anyway.

Yes, GTK3 already has it all working!

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