PDA

View Full Version : Compiling Qt with MySQL support on Windows 7 with MinGW.



Diath
26th May 2011, 09:45
Hello, I decided to make an application to manage my database with Qt and found out that I need to re-compile Qt in order to get MySQL plugin to work. So, I've installed MinGW and tried to compile it.

First of all, I had to configure, so I used following command:

configure -static -release -nomake examples -nomake demos -platform win32-g++ -qt-sql-mysql

And to compile:

mingw32-make

Then I had some errors about missing win32-g++, but I fixed it by adding env paths in Windows. After that, I received error about missing mysql.h header, so I downloaded MySQL connector from this URL: http://www.mysql.com/downloads/connector/cpp/.
Now I'm getting this error:


In file included from kernel\qsqldatabase.cpp:54:0:
kernel\/../drivers/mysql/qsql_mysql.h:108:33: error: expected ')' before '*' tok
en
mingw32-make[2]: *** [tmp/obj/release_static/qsqldatabase.o] Error 1
mingw32-make[2]: Leaving directory `E:/Qt/2010.05/qt/src/sql'
mingw32-make[1]: *** [release] Error 2
mingw32-make[1]: Leaving directory `E:/Qt/2010.05/qt/src/sql'
mingw32-make: *** [sub-sql-make_default-ordered] Error 2


Basing on this log I suppose that error is at line 108, but this line doesn't tell me much:

Q_UNUSED(tc);

Is there anyone that could assist me with fixing this?

liprandi
27th May 2011, 01:22
Did you try to execute bin\qtvars.bat before to call configure and mingw32-make?

Q_UNUSED(tc) just informs the compiler that the parameter tc will not use in the function.

Diath
27th May 2011, 15:51
Did you try to execute bin\qtvars.bat before to call configure and mingw32-make?
I don't have such file in bin directory.

Diath
31st May 2011, 01:13
So anyone who could point me out on how to get MySQL driver working with Qt?

ChrisW67
31st May 2011, 04:05
Are you deliberately building a static version of Qt?
Do you want a dynamically loadable plugin or a built-in driver?
We are told Windows, but which version of Qt?
The MingW bundled in the Qt SDK, or another?
Have you bothered to look at the lines before 108 (which incidentally looks nothing like that in my sources)?
Have you tried anything else in the last few days?

Have you read http://www.qtcentre.org/threads/23974-Build-Mysql-plugin-for-Qt ?
Have you read http://developer.qt.nokia.com/forums/viewthread/2081 ?

Diath
1st June 2011, 00:19
Are you deliberately building a static version of Qt?
Yes, I do.


Do you want a dynamically loadable plugin or a built-in driver?
Think I want built-in driver, not sure what you mean by that.


We are told Windows, but which version of Qt?
I'm using Qt 4.7.3 now (installed new version today).


The MingW bundled in the Qt SDK, or another?
Another one, the one I used previously (before I've installed Qt).
It is:

C:\Users\Tomek>mingw32-make -v
GNU Make 3.82
Built for i386-pc-mingw32
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


Have you bothered to look at the lines before 108 (which incidentally looks nothing like that in my sources)?
Seems like I was looking for it in wrong file previously, it's QMYSQLDriver class. I don't see anything wrong with it tho, here it is: http://pastebin.com/raw.php?i=ecNjUy0x


Have you tried anything else in the last few days?
Yeah I did, I've messed up everything so bad I decided to re-install Qt (using newest version now, as I wrote earlier).


Have you read http://www.qtcentre.org/threads/23974-Build-Mysql-plugin-for-Qt ?
Have you read http://developer.qt.nokia.com/forums/viewthread/2081 ?

Tried to follow these steps: http://www.qtcentre.org/threads/23974-Build-Mysql-plugin-for-Qt?p=116551#post116551
But still same output, here's my console session log:


Setting up a MinGW/Qt only environment...
-- QTDIR set to E:\Qt\4.7.3
-- PATH set to E:\Qt\4.7.3\bin
-- Adding D:\Services\MinGW\bin to PATH
-- Adding C:\Windows\System32 to PATH
-- QMAKESPEC set to win32-g++

E:\Qt\4.7.3>D:

D:\>cd services/mingw

D:\Services\MinGW>cd %QTDIR%/src/plugins/sqldrivers/mysql

D:\Services\MinGW>cd %QTDIR%/src/plugins/sqldrivers/mysql

D:\Services\MinGW>E:

E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=D:\Serv
ices\MinGW\include" "LIBS+=D:\Services\MinGW\lib\libmysql.a" mysql.pro
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.
WARNING: (internal):1: Unescaped backslashes are deprecated.

E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=D:\\Ser
vices\\MinGW\\include" "LIBS+=D:\\Services\\MinGW\\lib\\libmysql.a" mysql.pro

E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `E:/Qt/4.7.3/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_SQL_LIB -
DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_H
AVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\inclu
de\QtSql" -I"..\..\..\..\include" -I"d:\Services\MinGW\include" -I"..\..\..\..\i
nclude\ActiveQt" -I"debug" -I"..\..\..\..\mkspecs\win32-g++" -o debug\main.o mai
n.cpp
In file included from main.cpp:44:0:
../../../sql/drivers/mysql/qsql_mysql.h:108:33: error: expected ')' before '*' t
oken
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make[1]: Leaving directory `E:/Qt/4.7.3/src/plugins/sqldrivers/mysql'
mingw32-make: *** [debug] Error 2

E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>

ChrisW67
1st June 2011, 01:14
Looking at your session log I am puzzled. In the Qt source (4.7.2 or GIT repo) there is no file mysql.pro in the src\plugins\sqldrivers\mysql folder. Where has that come from? The resulting compilation commands do not include your MySql include directory, which is why the compile fails.

Have you read the README.module (http://qt.gitorious.org/qt/qt/blobs/4.7/src/sql/README.module) in src/sql ? Have you reconfigured Qt with the relevant "-qt-sql-mysql" or "-plugin-sql-mysql" option? You will need the -I option and probably a -L option to configure. After that you just rebuild Qt and the plugin should be included.