How to install MySql Driver?
-
You need to install reimp for MinGW, the paths might have changed in between but the basics stay the same
-
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 -
so you haven't followed the instructions carefully. all the steps mentioned by SGaist was completely described.
-
this is the first time i hear about rimp
-
checkout http://www.qtexperts.ir/wiki/index.xhtml/ساخت_درایور_MySQL for build instructions in Persian
-
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 -
-
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/"
-
-
Ok, but there are many files in my “C:\QtSDK\QtSources\4.8.1\lib”, and in my path/plugins/sqldrivers these files exist:(libqsqlite4.a, libqsqlited4.a, libqsqlmysql4.a, libqsqlmysqld4.a, qsqlite4.dll, qsqlited4.dll, libqsqlmysql4.a, qsqlmysqld4.dll) and empty 'mysql' folder.
are those enough?
I need to say i just serch 'QMYSQLDriver' then i find it in few directories:
C:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql
C:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtSql
C:\QtSDK\QtSources\4.8.1\include\QtSql
C:\QtSDK\Simulator\Qt\mingw\include\QtSql
can I use them? how do I use them? -
however Qt keeps binary compatibility but it's better to use plugins built with same version. I can't further help you making that plugin available in your project since i don't know how Qt's configured and defined on your system.
i just can point you to review the path of Qt version in use both on Environment Variables/QTDIR and QtCreator/options/build&run/Qt Versions once again. -
ok thanks all of you.
-
Hey guys, i'm having a similar problem and my context is very similar.
I'm trying to compile the mysql driver using qt5 and mysqlserver 5.6, using mingw too and tryed to follow the tutorial "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows. I did the reimp sucessfully creating the libmysql.a, i used the configure command sucessfully, but got an error trying to compile using mingw32-make sub-src. The errors are undefined references when trying to compile the mysql module.
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"
mingw32-make sub-src
@mingw32-make[3]: Entering directory 'C:/Users/Hugo/Downloads/qt-everywhere-opensource-src-5.0.1/qtbase/src/sql'
g++ -shared -Wl,--out-implib,C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\lib\libQt5Sqld.a -o ....\lib\Qt5Sqld.dll object_script.Qt5Sqld.Debug -lmysql -LC:/PROGRA~1/MySQL/MYSQLS
~1.6/LIB -LC:/Users/Hugo/Downloads/qt-everywhere-opensource-src-5.0.1/qtbase/lib -lQt5Cored .obj\debug_shared\Qt5Sqld_resource_res.o
./.obj\debug_shared\qsql_mysql.o: In functioncodec': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:223: undefined reference to
mysql_character_set_name@4'
./.obj\debug_shared\qsql_mysql.o: In functionqMakeError': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:234: undefined reference to
mysql_error@4'
C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:237: undefined reference tomysql_errno@4' ./.obj\debug_shared\qsql_mysql.o: In function
qMakeStmtError':
C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:309: undefined reference tomysql_stmt_error@4' C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:312: undefined reference to
mysql_stmt_errno@4'
./.obj\debug_shared\qsql_mysql.o: In functionZN19QMYSQLResultPrivate12bindInValuesEv': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:358: undefined reference to
mysql_stmt_result_metadata@4'
@ -
Anyone?
I guess my problem is with the reimp not generating a usable libmysql.a, when i use the reimp in the mingw-utils0.3 i got the output just fine, but all the procedures as i described before fail. When downloading the last version of mingw-utils(0.4) i try to use de reimp but it says libmysql.lib is corrupted or something... so i guess this is where the problem come from.
Any thoughts? help?