This turned out to be a multi-part problem.
The answer to the original question is that Qt looks for the libraries in the working directory (QDir::currentPath()
) and in the Windows PATH.
Part 1:
On Windows, the specified module could not be found
error also can mean that one of mod_spatialite.dll dependencies was not found. In my case, I had forgotten to move these dependencies to the same directory as mod_spatialite.dll. They include:
- libgcc_s_dw2-1.dll
- libstdc++-6.dll
- libsqlite3-0.dll
- libxml2-2.dll
- zlib1.dll
- libfreexl-1.dll
- libgeos_c-1.dll
- libgeos-3-5-0.dll
- libiconv-2.dll
- liblzma-5.cll
- libproj-9.dll
Part 2:
The libgcc_s_dw2-1.dll
and libstdc++-6.dll
libraries shipped with libspatialite do not work with Windows 10. Read more about this here and here. They would crash the program when loaded. The fix for me was to grab the same libraries from my Qt installation at C:\Qt\5.11.3\mingw53_32.