Compiling Qt with MySQL support on Windows 7 with MinGW.
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:
Code:
configure -static -release -nomake examples -nomake demos -platform win32-g++ -qt-sql-mysql
And to compile:
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:
Code:
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:
Is there anyone that could assist me with fixing this?
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
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.
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
Quote:
Originally Posted by
liprandi
Did you try to execute bin\qtvars.bat before to call configure and mingw32-make?
I don't have such file in bin directory.
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
So anyone who could point me out on how to get MySQL driver working with Qt?
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
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/2397...-plugin-for-Qt ?
Have you read http://developer.qt.nokia.com/forums/viewthread/2081 ?
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
Quote:
Originally Posted by
ChrisW67
Are you deliberately building a static version of Qt?
Yes, I do.
Quote:
Originally Posted by
ChrisW67
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.
Quote:
Originally Posted by
ChrisW67
We are told Windows, but which version of Qt?
I'm using Qt 4.7.3 now (installed new version today).
Quote:
Originally Posted by
ChrisW67
The MingW bundled in the Qt SDK, or another?
Another one, the one I used previously (before I've installed Qt).
It is:
Code:
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.
Quote:
Originally Posted by
ChrisW67
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
Quote:
Originally Posted by
ChrisW67
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).
Quote:
Originally Posted by
ChrisW67
Tried to follow these steps: http://www.qtcentre.org/threads/2397...551#post116551
But still same output, here's my console session log:
Code:
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>
Re: Compiling Qt with MySQL support on Windows 7 with MinGW.
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 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.