PDA

View Full Version : QMYSQL driver not loaded



stef1570
9th December 2011, 15:35
Hi all,

I have a problem with the mysql driver plugin.
I use Qt 4.7.4, MSVC 2008 and Windows 7 - 64 bit.

Source code is:

db = QSqlDatabase::addDatabase("QMYSQL");

Error code is:
Failed to connect to the database
Driver not loaded

Available drivers:

QSQLITE
QODBC3
QODBC

I tried to use both the 32 and 64 bit version of the libmysql.dll without success.

Available plugins in the plugins folder are:
C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers>dir *.dll
Il volume nell'unità C è Disco locale
Numero di serie del volume: BAB5-C1FD

Directory di C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers

14/11/2011 12:48 4.208.128 libmysql.dll
23/08/2011 16:07 416.256 qsqlite4.dll
23/08/2011 16:07 613.888 qsqlited4.dll
06/12/2011 15:51 58.880 qsqlmysql4.dll
06/12/2011 15:51 120.320 qsqlmysqld4.dll
23/08/2011 16:07 88.576 qsqlodbc4.dll
23/08/2011 16:07 162.304 qsqlodbcd4.dll
23/08/2011 17:01 119.808 qsqlpsql4.dll
23/08/2011 17:01 229.888 qsqlpsqld4.dll
9 File 6.018.048 byte
0 Directory 14.270.353.408 byte disponibili

The mysql plugin seems well compiled to me. What i did is:

QMAKESPEC=C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\mkspe cs\win32-msvc2008

cd %QTDIR%\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\lib\libmysql.lib" mysql.pro
nmake

and i got qsqlmysql4.dll and qsqlmysqld4.dll

qsqlmysqld4.dll exported function are (using dll export viewer)
qt_plugin_instance 0x1000126c 0x0000126c 1 (0x1) qsqlmysqld4.dll C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers\qsqlmysqld4.dll Exported Function
qt_plugin_query_verification_data 0x100011b8 0x000011b8 2 (0x2) qsqlmysqld4.dll C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers\qsqlmysqld4.dll Exported Function

qsqlited4.dll exported function (using dll export viewer)
qt_plugin_instance 0x10001410 0x00001410 1 (0x1) qsqlited4.dll C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers\qsqlited4.dll Exported Function
qt_plugin_query_verification_data 0x100012cb 0x000012cb 2 (0x2) qsqlited4.dll C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldriv ers\qsqlited4.dll Exported Function

It seems ok to me...

I red similar threads in the forum but no solution unfortunatly :(.

Has anybody solved this problem ?

Stefano

lekhrajdeshmukh
12th December 2011, 05:59
Hi,
You require following file to make connectivity with Mysql db server.
qsqlmysql4.dll
libqsqlmysql4.a

See below link to build mysql library.
http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/