Where does the Qt sqlite plugin look for extension libraries
-
I have made the appropriate modification as found in this thread to enable the Qt sqlite plugin to load extensions. However, when I run
SELECT load_extension('spatialite_mod')
, I now get the errorThe specified module could not be found
On a Windows Qt installation, where do I need to put the
spatialite_mod.dll
file so that it can be found a runtime? I have already tried putting it in the binary directory without any success. -
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
andlibstdc++-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. -
Hi,
Did you try to pass the full file path ?
Or if you have it one the same folder as your application, "./name.dll".
-
What about relative to your driver? I see that they get the driver from the DB object so my guess is either relative to the driver or the .db file.
For example when running through the qt creator IDE it should look at the folder which contains the sql drivers(unless you have put your dependencies in your local build folder).
On my Qt version 5.12.0 64 bit mingw that folder is located here: C:\Qt\5.12.0\mingw73_64\plugins\sqldrivers
Did you try that?
I tried googling a bit and only see code examples but no statements on WHERE the extension should be placed...
-
Can you provide a minimal compilable example ?
This way we may also test on our end to find out. -
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
andlibstdc++-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. -
Thanks for the detailed feedback !