Qt & SQLite deploy problems.
-
wrote on 30 Jul 2011, 09:32 last edited by
[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]
-
wrote on 30 Jul 2011, 10:17 last edited by
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.
-
wrote on 30 Jul 2011, 11:06 last edited by
[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. -
wrote on 30 Jul 2011, 13:54 last edited by
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.. -
wrote on 1 Aug 2011, 07:38 last edited by
Hi Zither,
I simply get "Driver not loaded." But I know this is the case since if I restore the SDK path it works just fine.
It simply won't run qsqlite4.dll out of ./plugins/sqldrivers/ nor ./sqldrivers/Thanks.
-
wrote on 3 Aug 2011, 00:23 last edited by
Are you sure you copied the correct qsqlite4.dll ?
There is an incompatible one in QtSDK/QtCreator/bin/sqldrivers and if you are compiling in debug mode, you should probably copy qsqlited4.dll instead of qsqlite4.dll in ./sqldrivers directory. -
wrote on 3 Aug 2011, 08:38 last edited by
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.
-
wrote on 11 Oct 2011, 01:39 last edited by
Hi Guys,
I am still struggling with this problem. Does anyone have any other suggestions?
I have tried multiple systems and different installs of Mingw & Qt with the same result every time.
-
wrote on 8 Nov 2014, 19:35 last edited by
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.
-
wrote on 9 Nov 2014, 23:56 last edited by
For the record;
This problem was fixed up by eventually grabbing a later release (think I built from source too).