Problems with GTK4 on Windows 11

Hi,
I am currently learning how to develop a GTK4 (+ Rust) app. However, my app should target both Linux and Windows. Unfortunately, I am facing issues when it comes to running the app on Windows. I have been trying to debug this for one week now, and I documented and automated everything, so it should be easy to reproduce.

Problem:

Following the instructions from the repository I linked down below for Windows and Linux works fine, and in the end, the app window pops up.
However, on Windows, when running the app from the Windows file explorer, it returns a bunch of errors about missing dlls. I suppose I need to add those to the bin directory where the executable of the app is located, so I did that manually. When running the app again through the Windows file explorer after adding all missing dlls (I just copied the entire msys2 ucrt64/bin directory), a cmd.exe window opens. After some time, the application itself opens too.

Questions (about the Windows build):

  • How can I automate the process of putting all dlls into the bin directory? I know I could add some instructions in the meson scripts, but that would require me to type out the names of dozens of dlls. In addition, if a dependency ever becomes unused, or a new one is added, I will have to adjust the scripts in this project accordingly. Is there some way to automate that? The closest I can get to fetching all dependencies is by running pkg-config --cflags --libs gtk4, but that doesn’t seem ideal either, and I don’t know what to do with the output.
  • How do I get rid of the cmd.exe window that opens when opening my application through the Windows file explorer?
  • How to reduce the time it takes for the app to start?
  • Is there some way to package everything into just one .exe file? I don’t want users to have to download a zip file with my app, or to have to use an installer. The app will never become large enough to justify that. Also, I don’t mind the app becoming a couple of megabytes larger to include all needed libraries.

The following repository contains the entire project and detailed instructions on how to reproduce my Issue: Tobias Linz / myapp · GitLab

Hello, @tobilinz!

There’s no such tool, AFAIK. Most projects tend to develop a custom script which creates a bundle. However you can use Meson with subprojects to build and install all the dependencies (even if you use cargo or other build systems): Build and run GTK 4 applications with Visual Studio

That happens when the EXE subsystem is set to console : How to make a program that does not display the console window? - Stack Overflow

This is a known issue: cold startups are slow because Pango scans all fonts in the system. Anyway this is on my to-do list :slight_smile:

You can consider making a full-static build (again, Meson is probably the best tool), perhaps including the CSS theme and icons as GResources.

1 Like

Thanks for the answer!

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