Qt & SQLite deploy problems.
-
Is the displayed message "driver not loaded driver not loaded"?
-
[quote author="Stavros" date="1311941555"]Is the displayed message "driver not loaded driver not loaded"?[/quote]
The program (in release mode) is just giving me a seg fault on a vanilla test machine. But I can clear this up be removing the QMessageBox error on the loading of the db. (of course the DB is still not loaded); so technically no error is returned, it just seg faults.
@
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbName);
if(!db.open()){
qDebug() << "Couldn't db.open()";
QMessageBox::critical(0, qApp->tr("Cannot open database"), db.lastError().text(), QMessageBox::Cancel);
return false;
}
@[EDIT: fixed code formatting, please use @-tags, not "code", Volker]
-
-
[quote author="zither" date="1311954455"]In your application folder, make a directory namely "sqldrivers" & copy qsqlite.dll file to there. E.g.,
Applications Folder
->YourApp.exe
-> sqldrivers\qsqlite.dllIt's work. No need to add library path unless you want to place that file @ specific place
[/quote]Hi zither,
I have already done as you suggested but the database still fails to load. Additionally I am also experiencing a seg fault at the QMessageBox in the code below; are these two errors maybe related, can you see anything I am missing?
@
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(dbName);
if(!db.open()){
qDebug() << "Couldn't db.open()";
QMessageBox::critical(0, qApp->tr("Cannot open database"),db.lastError().text(), QMessageBox::Cancel);
}
@I can also confirm that the error is "Driver not loaded Driver not loaded."
[EDIT: fixed code formatting, please use @-tags, not “code”, Volker]
-
Well, I would make an guess here: ;-)
Investigate the possibility that the “Driver not loaded Driver not loaded.” and the SEG FAULT are two different problems.
-
[quote author="Stavros" date="1312021044"]Well, I would make an guess here: ;-)
Investigate the possibility that the “Driver not loaded Driver not loaded.” and the SEG FAULT are two different problems. [/quote]
Thanks Stavros, my question obviously wasn't clear.
Could the failure to load the db driver and the subsequent failure of db.open() cause any future calls, such as db.lastError().text(), to result in an access violation?
I realise this is a separate issue though, which I'll handle once I get the library loaded, I was just wondering at the time of writing the post. -
To differentiate library can't available or file error, use this code
@db = QSqlDatabase::addDatabase("QSQLITE");
if (!db.isDriverAvailable("QSQLITE"))
QMessageBox::warning(this,"Error",db.lastError().text());@If no library in path, error will prompt "Driver not loaded ...".
Otherwise, that may be file error.. -
-
To get information from Qt about the loading of the plugin, you can use the "QT_DEBUG_PLUGINS ":http://doc.qt.nokia.com/latest/deployment-plugins.html environment variable. This might help you to find the cause of the problem. Set this variable to a non-zero value in the environment from which your application is launched.
-
QT 5.3.1
Using qsqliteI had this same problem and solved with a shotgun approach. I knew it was missing the dll, just didn't know where so I put the dll everywhere, presto it works. Then with the application still running I attempted to delete each of the eight qsqlite.dll files. I could delete 7, one of them was locked. Excellent.
So it seems that with a deployed application you want to create a "sqldrivers" folder beside the platforms folder and place your sql dll in there. Here is my layout:
My.exe
Qt5Core.dll
Qt5Sql.dll
+\platforms ( qwindows.dll, qoffscreen.dll, qminimal.dll )
+\sqldrivers ( qsqlite.dll )Cheers All,
Derrek -
Thanks for sharing your solution, Derrek. For future reference, the procedure is documented at http://qt-project.org/wiki/Deploy_an_Application_on_Windows (diagram below).
Note that your program will only use qwindows.dll, so you don't need qofscreen.dll and qminimal.dll.