Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
MySql plugin for windows
I tried today to port one of my soft on windows (with Qt creator, basic install). but I can't build the QMYSQL Plugin. I look at the doc who say
qmake "INCLUDEPATH+=C:\MySQL\include" "LIBS+=C:\MYSQL\MySQL Server <version>\lib\opt\libmysql.lib" mysql.pro
I tried it but the windows "power" shell didn't recognize qmake. I'm not an expert on windows and I could use a little help on this.
goetz last edited by
Just call qmake by it's full path.
Thanks Volker. (I guess I was tired ..), Now I get this error (in command-line and in Qtcreator)
@qsql_mysql.obj:-1: erreur : LNK2019: unresolved external symbol _mysql_list_tables@8 referenced in function "public: virtual class QStringList __thiscall QMYSQLDriver::tables(enum QSql::TableType)const " (?tables@QMYSQLDriver@@UBE?AVQStringList@@W4TableType@QSql@@@Z)@
for 50 different link.
here is my .pro :
@TARGET = qsqlmysql
SOURCES = main.cpp
C:\MySQL\ is my MySQL install dir, i used the MySQL Community Server 5.5.12.
the libmysql.lib link is correct and i don't understand why it's not working.
andre last edited by
The problem is, that MySQL is build using the MSVC compiler, and you can't just link against it using MinGqw32 without doing "some other work":http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Windows_using_MinGW first.
I followed this link before trying with Qtcreator,
It generate the makefile, the makefile.debug and makefile.release but when i use mingw32-make on it I got this:
@Makefile.Debug:61: *** missing separator. Stop.
mingw32-make: Leaving directory `C:/QtSDK/QtSources/4.7.3/src/plugins/sqldrivers/mysql'
mingw32-make: *** [debug] Error 2@
the corresponding line on makefile.debug is :
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Fodebug\ @<<
(line 4 here)
aurorius last edited by
Try reading this post: "Enabling MySQL Plugin":http://www.pikopong.com/blog/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows-part-2/
ucomesdag last edited by
[quote author="aurorius" date="1310598231"]Try reading this post: "Enabling MySQL Plugin":http://www.pikopong.com/blog/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows-part-2/[/quote]Just one remark on the the howto you refer to. It would be cleaner to copy libmysql.dll to the bin directory where all the Qt dll's live.
Don't forget to distibute libmysql.dll with your executable and ship qsqlmysql4.dll in the subdirectory sqldrivers (relative to your executables root)
p91paul last edited by
the tutorial says that you have to copy libmysql.dll in C:\Windows; in fact I have copied it in Qt/Desktop/Qt/4.7.3/mingw/bin and it works without using system directories. When deploying, you have to follow ucomesdag advice.
[quote author="aurorius" date="1310598231"]Try reading this post: "Enabling MySQL Plugin":http://www.pikopong.com/blog/2011/07/11/how-to-enable-mysql-support-in-qt-sdk-for-windows-part-2/[/quote]
Thanks!!! The first tutorial which worked perfectly!!!
Thanks once again!!
Actually it doesn't=) Because there is no such command as reimp or may be in qt command promt what I have is something wrong............
There is no need to reimp a thing... check the tutorial
I did it. So I got the following result:
mingw32-make -f Makefile.Debug
mingw32-make: Entering directory
E:/QtSDK/QtSources/4.7.4/src/plugins/sqldrivers/mysql' g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_ ngw\include\QtCore" -I"e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql" -I"e:\QtSDK\Desktop\Qt\4.7.4\mingw\include" -I"c:\PROGRA~2\MySQL\MYSQLS~1.5\inclu In file included from ../../../sql/drivers/mysql/qsql_mysql.h:52, from main.cpp:44: e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:70:27: error: mysql_version.h: No such file or directory e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:71:23: error: mysql_com.h: No such file or directory e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:72:24: error: mysql_time.h: No such file or directory e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:74:70: error: my_list.h: No such file or directory e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:132:21: error: typelib.h: No such file or directory e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:147:22: error: my_alloc.h: No such file or directory In file included from ../../../sql/drivers/mysql/qsql_mysql.h:52, from main.cpp:44: e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:115: error: use of enum 'enum_field_types' without previous declaration e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:153: error: 'MEM_ROOT' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:260: error: 'NET' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:266: error: 'MEM_ROOT' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:285: error: 'SCRAMBLE_LENGTH' was not declared in this scope e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:302: error: ISO C++ forbids declaration of 'LIST' with no type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:302: error: expected ';' before '*' token e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:326: error: 'MEM_ROOT' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:350: error: 'NET' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:518: error: use of enum 'mysql_enum_shutdown_level' without previous declaration e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:525: error: use of enum 'enum_mysql_set_option' without previous declaration e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:662: error: 'NET' has not been declared e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:673: error: use of enum 'enum_field_types' without previous declaration e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:685: error: 'MEM_ROOT' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:686: error: 'LIST' does not name a type e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:714: error: 'MYSQL_ERRMSG_SIZE' was not declared in this scope e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:715: error: 'SQLSTATE_LENGTH' was not declared in this scope e:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql/mysql.h:757: error: use of enum 'enum_server_command' without previous declaration mingw32-make: *** [debug/main.o] Error 1 mingw32-make: Leaving directoryE:/QtSDK/QtSources/4.7.4/src/plugins/sqldrivers/mysql'
mingw32-make: *** [debug] Error 2
The problem is with your SQL Library, it was not properly included into the project.
Thank you for you answers.
I guess, I have to install qt and mysql on the same disk and see, what will happen. Because in command prompt for some reason I can't change the disk letter. May be only problem was in a drive letter. I'm not sure. In linux it wasn't that hard.