QtSQL drivers not loaded on client PC
-
Hi, I created app which using QtSQL plugins (QIBASE, QMYSQL, QMSSQL, QDB2).On my PC all work fine, but I moved to another PC without QtSDK I have output:
@Driver not loaded Driver not loaded@
I solved depencies and I copy drivers dll's to subdir plugins:
C:\myapp
C:\myapp\plugins
I use depency walker to get all depencies to database drivers and copy it to plugins dir. I edit my app to read plugins from plugins dir using QCoreApplication::addLibraryPath :
@int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCoreApplication::addLibraryPath(a.applicationDirPath() + "/plugins");
formIndex w;
w.show();
return a.exec();
}@
I know there is lot of solutions on internet and I try to solve this alone but I can't find good solution for me -
all dll's from sql need to be in a folder called "sqldrivers" that would be within the plugins folder of your application
-
I created dir sqldrivers under plugins:
C:\myapp
C:\myapp\plugins\sqldrivers
I edited my app main file:
int main(int argc, char *argv[])
@{
QApplication a(argc, argv);
QStringList pathList;
pathList.append(a.applicationDirPath());
pathList.append(a.applicationDirPath() + "/plugins");
QCoreApplication::setLibraryPaths(pathList);
qDebug() << a.libraryPaths();
formIndex w;
w.show();
return a.exec();
}@
Inside plugins/sqldrivers are all sql drivers depencies include QtCore4.dll etc.
And now I run my app still nothing, what I do wrong? -
On deployment computer don't need to create plugins folder. So the folder structure should like:
app
app/sqldriversAlso for windows application, there is no need to call
@
QCoreApplication::setLibraryPaths
@edit: in sqldrivers folder is enough to put only sql plugins (qsqlmysql4.dll, etc ... without Qt dependencies)
-
You can put all dependencies anywhere in "KnownDLLs" locations ( see "Dynamic-Link Library Search Order":http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx), or you can put them near your executable
-
I made an app that used the db name:
@
"DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=" + SourceDB + ";"
@It rans perfectly on my dev machine but some clients returned "Driver not found" when the process hit this line of code.
The fix was to include on client machines the file:
@
sqldrivers\qsqlodbc4.dll
@I.e. if my app was in
@
c:\myApp\app.exe
@...then the dll was copied to:
@
c:\myApp\sqldrivers\qsqlodbc4.dll
@Note that this fixed the "Driver not found" on the Win32 version of my app, however, the x64 version still fails as there isn't a 64b version of the microsoft ODBC drivers.