[Windows 11 - GTK4] Cannot find and load SVG module on test VM at runtime

The Environment:

Windows 11, GTK4 and libadwaita-1 provided by MinGW64.

The Problem:

When the application is run on the test VM, the gdk-pixbuf svg module is not being found at runtime and svg’s are not loading.

The Situation:

The application runs as expected on my Windows 11 development machine but after I package the binary and supporting files, SVG files will not load on the Windows 11 testing VM.

The file structure is what many have suggested (namely here) through various posts, following the format of:

├ bin
├─ … (dll’s)
├ lib
├── 2.10.0
├─── loaders
├──── libpixbufloader-png.dll
├──── libpixbufloader-svg.dll
├──── …
├─── loaders.cache
├ share
├── schemas
├─── …
├── adwaita
├─── …

My Windows install script uses ldd to find and copy the dependencies of the binary, which includes librsvg-2-2.dll. I intend to run gdk-pixbuf-query-loaders after installing on the testing VM to update the loaders.cache file, so I also search and include it’s dependencies in my bin folder.

Attempts to Fix:
Following the thread from this post, I rebuilt gdk-pixbuf from source with -Dbuiltin_loaders=all, -Drelocatable=true and -Dnative_windows_loaders=true. Running gdk-pixbuf-query-loaders.exe --update-cache on the test vm creates the loaders.cache file in the lib\gdk-pixbuf-2.0\2.10.0 directory with # LoaderDir = c:\lib\gdk-pixbuf-2.0\2.10.0\loaders at the end of the file.

Perhaps some of my environment variables are not set correctly for the project? I must admit, I do not have a great understanding of what they should be in my particular case (trying to run the app outside of the dev environment).

What is strange is that the console log can point to where libpixbufloader-svg is but says that the module cannot be found. Maybe I am missing another dependency that isn’t being picked up by my script?

From the test VM:

(eosMonosync.exe:6996): Gtk-WARNING **: 14:46:45.290: Failed to load icon C:\Users\arctagon\Documents\eosMonosync\share\icons\Adwaita/symbolic/status\weather-clear-symbolic.svg: Unable to load image-loading module: C:\Users\arctagon\Documents\eosMonosync\lib\gdk-pixbuf-2.0\2.10.0\loaders\libpixbufloader-svg.dll: ‘C:\Users\arctagon\Documents\eosMonosync\lib\gdk-pixbuf-2.0\2.10.0\loaders\libpixbufloader-svg.dll’: The specified module could not be found.

Advice would be greatly appreciated! Thanks

Hi @arctagon!

The gdk-pixbuf project comes with several loaders which can even be included “statically”, but the SVG loader is developed elsewhere: it’s part of librsvg: gdk-pixbuf-loader · main · GNOME / librsvg · GitLab

As such it can’t be included statically. The error message you’re getting means that some dependencies of libpixbufloader-svg.dll cannot be found (in your bin\ directory). Ensure that you have:

  • bin\librsvg-2-2.dll
  • bin\libxml2-2.dll
  • bin\libiconv-2.dll
  • bin\libcharset-1.dll
  • bin\zlib1.dll

If those are missing, just copy them from your MSYS2 installation

That solved the issue, thank you! Oddly enough I wasn’t using ldd on libpixbufloader-svg.dll. I did notice that libcharset-1.dll is not listed by ldd so I had to create a separate line to find/include it as well. I can now run gdk-pixbuf-query-loaders.exe --update-cache ..\lib\gdk-pixbuf-2.0\2.10.0\loaders\libpixbufloader-svg.dll to generate the SVG related output in the loaders.cache file. Previously it was reporting that the module could not be loaded. Much appreciated!!

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