PDA

View Full Version : Release version of Application not connecting to MySql Database



Barry79
10th August 2009, 15:13
Hi there,

I get the following error when I try to connect to a mysql database.

QMYSQL driver not loaded

for the release version of my application.

I don't get this error for the debug version, which connects as expected.

I am working on Windows XP with VS2008.

I have built QT as follows -

C:\Qt\2009.02\qt\src\plugins\sqldrivers\mysql>configure -no-qt3support -platform win32-msvc2008 -no-libtiff -no-phonon -no-phonon-backend -no-webkit -qt-sql-mysql -l libMySql -I C:\mysql\include -L C:\mysql\lib\opt -static -release

C:\Qt\2009.02\qt\src\plugins\sqldrivers\mysql>nmake sub-src

And have directed the linker to link against -

C:\Qt\2009.02\qt\lib\QtSqld4.lib

for both release and debug.

Any idea what the problem might be?

Thanks,

Barry

giowck
10th August 2009, 15:22
http://doc.qtsoftware.com/4.5/plugins-howto.html

The fastest and easiest way is to create a directory called "sqldrivers" where the main executable is, and in that folder you have to put the right sql driver .dll

See under your qt folder in the directory plugin (C:/../qt/plugins/sqldrivers/)

Barry79
10th August 2009, 15:51
Thanks very much for the reply!!!

I copied the folder -

C:\Qt\2009.02\qt\plugins\sqldrivers

to my applications bin folder. Now I am informed that I have 1 available driver when I run the application - QSQLITE, whilst before I had none. However I still get the message -

QSqlDatabase: QMYSQL driver not loaded

What should I have in the sqldrivers folder with regards to mysql?

I currently have -

qsqlite4.dll
qsqlite4.exp
qsqlite4.lib
qsqlite.lib
qsqlited4.dll
qsqlited4.exp
qsqlited4.lib
qsqlmysql.lib

I'm guessing I need something like qsqlmysql.dll

Any ideas?

Thanks,

Barry

kornicameister
9th February 2011, 20:30
first before first of all, I assume the problem exists on Windows platform, because installing appropriate packet on for example Debian is only typing qmysql (or something similar) in Synaptic

than you're facing with the same problem as I do
first of all, yes You need dll file as you posted

this is explained here for example http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW

secondly, depeding on your type of Qt installation (static or sharing libs) there are two ways two follow.
By default Qt is installed with sharing, here is the description http://doc.qt.nokia.com/4.7/deployment-windows.html

nevertheless I am convinced that not only qsqlmysql4.dll is required to be attached to executable file, but also libMySQL.dll which can be found in MySql installation folder.

only after I'd added this dll my program reported than it has a valid mysql driver.
using http://www.dependencywalker.com/ I noticed that qsqlmysql4.dll is loaded properly but application can not find libmySQL.dll file

how this can be explained ? I mean, why qsqlmysql4.dll is not enough here ?