[SOLVED] Why my Qt app does not find Qt plugins?
We're working on a cross-platform (win-mac) app. It works on development machines. But somehow it cannot find the required Qt plugins (sqlite driver for example) on other machines. I tried on 2 virtual machines (XP SP2 and XP SP3) and on 1 real one (XP SP3), none of them found the plugins. The app starts and works, it simply does not find the required plugins, only on development machines - I checked, and even on dev machines it loads the plugins from QtSDK folders, not from the folders containing exe. The Qt DLLs are loaded from the folder of the exe.
I even added a plugins/ folder manually:
And I print all the pathes Qt will search in ( QCoreApplication::libraryPaths(); ), and it prints both the appDir (contains the exe) and appDir/plugins (contains the plugins directories), but it just can't find them.
I use Qt 4.7.3 and MSVC 2008.
I assume you mean the sqlite plug-in of Qt, right?
it should be located in a sub dir of the executable named sqldrivers, so if your exe is under
C:\myPath, then the plugin should be in C:\myPath\sqldrivers
And it's there. Actually I copied the whole plugins/ folder from QtSDK's msvc2008 folder next to the exe. I also tried to put the folders in QtSDK's plugins/ folder directly next to the exe, as well to a plugins/ folder, but no luck so far.
The build version of the plugins, your Qt lib and your executable need to match exactly: same Qt version, same compilation flags, all in release or all in debug mode, etc.
I double checked them. Also as I wrote on my development machine (Win7) the app works, but when I checked the runtime dll dependencies with SysinternalSuite's procexp is shows that it loads the plugins from the QtSDK msvc2008/plugins folder (even if I don't start the app from QtCreator!). I copied exactly the same dlls, but it just can't find them somehow...
Could it happen because some MSVC redistributable dlls missing from the test machines? I copied all I found with SysinternalSuite's procexp, and the application starts and works, but is it possible that a Qt plugin cannot be loaded because it would require further MSVC redist dlls?
I just tried everything I could think about, but nothing works.
That is certainly possible. You can check that with a dependency walker.
I checked it with Dep.Walker, and I can't see any missing MSVC redist dlls. It uses:
msvcr90.dll and msvcp90.dll
I don't see any further MSVC redist dlls. (Both of these dlls are copied with the exe)
Ahh, I can't believe it... The qsqlite4.dll requires msvcr90.dll, which is next to the exe. But when it tries to load the dll I suppose it changes the working-directory to qsqlite4.dll 's folder, which does not contains msvcr90.dll.
If I copy msvcr90.dll next to qsqlite4.dll it can find it and the app can load the sqlite plugin. If only the exe directory contains msvcr90.dll then it can not...
Is this a common problem? Are there any solution no to have multiple msvcr90.dll s in every plugin folder?
This is important, because the app does not require any installation, and I don't want to install MSVC redistributable installer.