How to install MySql Driver?
-
wrote on 10 Mar 2013, 06:35 last edited by
It's about 3 days I'm working on install mysql driver but it hasn't worked. first i tested with xampp and didn't work, second i decided install mysql server but it didn't work either, i wrote this instructions in "Start>All Program>Qt SDK>Desktop>Qt 4.8.1 for Desktop (MinGW)"
@cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql
qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 5.6\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 5.6\lib" mysql.pro
make@but cmd show me 2 errors for example:
@ make[1]: ***[tmp/obj/debug_shared/main.o] Error 1
make[1]: leaving directory '/c/QtSDK/QtSources/4.8.1/src/plugins/sqldrivers/mysql'@I have no idea what i must to do. please tell me what must i do
-
wrote on 10 Mar 2013, 10:21 last edited by
Maybe it will be helpful for you
"Create MySQL driver for Qt5":http://seppemagiels.com/blog/create-mysql-driver-qt5-windows -
wrote on 10 Mar 2013, 13:03 last edited by
- why do you use the path separator twice?
- which compiler do you use? msvc or mingw?
- have you read the "build instructions":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows?
-
wrote on 10 Mar 2013, 20:50 last edited by
Thank you for your consideration. when I use single path separator show me this WARNING let me show the code in single separator:
@C:\WINDOWS\system32>set mysql=C:\Program Files\MySQL\MySQL Server 5.6
C:\WINDOWS\system32>cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql
C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\Pro
gram Files\MySQL\MySQL Server 5.6\include" "LIBS+=C:\Program Files\MySQL\MySQL S
erver 5.6\lib\libmysql.lib" mysql.pro
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.@and my compiler is MinGW also I've read "This link":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
@aklenczar my version is 4.8.1 and test your way but it didn't work and it shows the same error.
by the way, i must say my OS is XP -
Hi,
Two things i can think of:
- you are missing a -L before your MySQL path in your LIBS statement
- Using spaces in lib path on windows has always been a problem (quoted or not, at least for me) I've always reverted to either having all paths without spaces or use the 8.3 names of the folders
Hope it helps
-
wrote on 11 Mar 2013, 11:00 last edited by
Hi SGaist.
my 'libmysql.ilb' file is in this directory:
C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib
and my 'include' folder in this:
C:\Program Files\MySQL\MySQL Server 5.6\include
so
I changed MySql path to this:@C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\PROGRA~1\MySQL\MYSQLS~1.6\include" "LIBS+=C:\PROGRA~1\MySQL\MYSQLS~1.6\LIB\LIBMYS~1.lib" mysql.pro@
although this code show me the same Error, may be I wrote wrong 8.3 name.
it's better to see if my path is correct or not -
Just to be sure, what compiler are you using ?
-
wrote on 11 Mar 2013, 15:30 last edited by
OK. my compiler is MinGW
-
Then you have to follow that set of "instructions":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-mysql-driver-for-mingw-users
-
wrote on 11 Mar 2013, 16:05 last edited by
my compiler is installed with qt creator in default setting, do you think is necessary download MinGW in order to this instructions?
-
No need to download another MinGW, use the one that came with Qt
-
wrote on 12 Mar 2013, 06:35 last edited by
I skip this part:
(Open the DOS prompt, go to C:\MySQL\MySQL51\lib\opt, and run the following commands:
reimp -d libmysql.lib
dlltool -k -d libmysql.def -l libmysql.a)
Because, it shows this message:@C:\PROGRA~1\MySQL\MYSQLS~1.6\lib>reimp -d libmysql.lib
'reimp' is not recognized as an internal or external command,
operable program or batch file.@also I don't have 'opt' folder, I just have 'C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib'
Then, I wrote this part:
@C:\QtSDK\QTSOUR~1\4.8.1>configure.exe -debug-and-release -platform win32-g++ -qt
-sql-mysql -l mysql -I C:\PROGRA~1\MySQL\MYSQLS~1.6\include -L C:\PROGRA~1\
MySQL\MYSQLS~1.6\lib@
and after long time this error appeared:
@mingw32-make[2]: *** [../../lib/QtSqld4.dll] Error 1
mingw32-make[2]: Leaving directoryc:/QtSDK/QTSOUR~1/4.8.1/src/sql' mingw32-make[1]: *** [debug-all] Error 2 mingw32-make[1]: Leaving directory
c:/QtSDK/QTSOUR~1/4.8.1/src/sql'
mingw32-make: *** [sub-sql-sub_src_target_ordered] Error 2@I think these error are for my version of Qt4.8.1 and mySql5.6 because these instructions are provided for MySql5.1 and Qt4.6.2, am I right?
-
You need to install reimp for MinGW, the paths might have changed in between but the basics stay the same
-
wrote on 12 Mar 2013, 11:34 last edited by
oh you're right. But if I run
@reimp -d libmysql.lib@will libmysql.def and libmysql.a be created?
Because I don't have them now in order to rest of the process. -
reimp to create libmysql.def
dlltool to create libmysql.a -
wrote on 12 Mar 2013, 12:03 last edited by
so you haven't followed the instructions carefully. all the steps mentioned by SGaist was completely described.
-
wrote on 12 Mar 2013, 12:39 last edited by
this is the first time i hear about rimp
-
wrote on 12 Mar 2013, 16:26 last edited by
checkout http://www.qtexperts.ir/wiki/index.xhtml/ساخت_درایور_MySQL for build instructions in Persian
-
wrote on 14 Mar 2013, 06:44 last edited by
I've done both of your ways, I succeeded to make libmysql.def and libmysql.a, Then I ran this code
@C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\Program Files\MySQL\MySQL Server 5.6\include -L C:\Program Files\MySQL\MySQL Server 5.6\lib@
(I used path with space because of -I and -L) after a while it shows many messages some of them is:@c:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug all
mingw32-make[3]: Entering directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
mingw32-make[3]: Nothing to be done forall'. mingw32-make[3]: Leaving directory
c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
c:/QtSDK/mingw/bin/mingw32-make -f Makefile.Release all
mingw32-make[3]: Entering directoryc:/QtSDK/QtSources/4.8.1/src/imports/shaders' mingw32-make[3]: Nothing to be done for
all'.
mingw32-make[3]: Leaving directoryc:/QtSDK/QtSources/4.8.1/src/imports/shaders' mingw32-make[2]: Leaving directory
c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
mingw32-make[1]: Leaving directory `c:/QtSDK/QtSources/4.8.1/src/imports'@
i ignored them and ran next step
@C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\PR
OGRA~1\MySQL\MYSQLS~1.6\include" "LIBS+=-L. mysql" mysql.pro@and i saw no error, but mysql driver wasn't installed.
i decided use Mohsen's method, with ran this method i have libqsqlmysql4.a
libqsqlmysqld4.a
qsqlmysql4.dll
qsqlmysqld4.dll
In "C:\QtSDK\QtSources\4.8.1\plugins\sqldrivers" i copied them to my project but when i run this code
@qDebug() << QSqlDatabase::drivers();@
i don't see qmysql driver -
wrote on 14 Mar 2013, 10:04 last edited by
-
if you're running your application through QtCreator you won't need to copy them into your app dir. it's just enough having them in "C:\QtSDK\QtSources\4.8.1\plugins\sqldrivers" just making sure your other Qt libs are in "C:\QtSDK\QtSources\4.8.1\lib" and this is the path where you've defined in QTDIR. otherwise if this is only the path of sources directory then you must move the result binaries onto the main Qt directory path/plugins/sqldrivers.
-
if you're trying to make a release then you'll need to have qmysql.dll and libmysql.dll in "[YOUR EXE PATH]/sqldrivers/"
-
1/25