gstplugin: Better warnings on plugin load failure on Windows
It is an extremely common mistake on Windows to have incorrect PATH
values when loading a plugin, and the error from g_module_error()
(which just calls FormatMessageW()
) is very confusing in this case:
The specified module could not be found.
https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-#ERROR_MOD_NOT_FOUND
It implies the plugin itself could not be found. The actual issue is that a DLL dependency could not be found. We need to detect this case and print a more useful error message.
We should still print the error fetched from FormatMessage()
so that
people are able to google for it.
The next thing we should do is to help people in debugging this issue by searching for missing DLLs recursively when a debug env var is set, like GST_DEBUG_PLUGIN_PRINT_MISSING_DLLS
. This is more work, since it either requires loading a library that allows us to parse PE DLLs, or writing some custom code to only parse out the dependents. However, it might be worth doing because it is often difficult to run a DLL dependency walker tool inside the same env as the app that is using gstreamer.
I wrote some Python scripts that do this using a pre-existing python module called pefile
: https://gitlab.freedesktop.org/nirbheek/gst-dll-tools, so it is definitely doable.