gtk4-rs: [BUG] Building with gvsbuild GTK4 no longer works with gvsbuild==2022.5.0: (LoadLibraryExW)

Bug description

  1. Build GTK4 with gvsbuild==2022.5.0
  2. Within gtk4-rs, check out 0.5.2 (though I tested with current master, 5a8e72b4d13bdf774b1aa479338fd08074f61a4e)
  3. cargo build.
C:\dev\gtk4-rs [master]> cargo clippy
...
    Checking gtk4 v0.6.0 (C:\dev\gtk4-rs\gtk4)
error: LoadLibraryExW failed
  --> gtk4\src\lib.rs:29:1
   |
29 | pub extern crate gtk4_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: cannot determine resolution for the import
  --> gtk4\src\auto\functions.rs:23:5
   |
23 | use glib::translate::*;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: import resolution is stuck, try simplifying other imports

...

Two other things worth mentioning:

  • This works with the last release of gvsbuild (2022.4.1)
  • I can still build a C-based GTK4 project in Visual Studio successfully

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

Ok, then I’m out of ideas. This would have to be debugged by someone actually on Windows. You somehow need to hook into the dynamic library loader to get more information about why the proc macro crate is failing to be loaded.

I think the problem here is that loading the proc-macro library into the compiler fails, most likely because a DLL is not found at build time. I don’t know how the exact file is called on Windows, but can you check target/debug/deps/libgtk4_macros-XXXXXXXXXX.dll or similar to see if there are missing DLLs? You can use https://github.com/lucasg/Dependencies for that.

Can you also check if this also happens after removing the gtk dev-dependency from gtk4-macros/Cargo.toml (second last line)?

My guess is that your environment is messed up, standard Windows DLL hell situation 😃 You either have to many paths in PATH (and it pulls in incompatible DLLs, the Windows git installer is often a good candidate for that), or you’re missing some path from PATH.