Results 1 to 7 of 7

Thread: Compiling Qt with MySQL support on Windows 7 with MinGW.

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question 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:
    Qt Code:
    1. configure -static -release -nomake examples -nomake demos -platform win32-g++ -qt-sql-mysql
    To copy to clipboard, switch view to plain text mode 

    And to compile:
    Qt Code:
    1. mingw32-make
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. In file included from kernel\qsqldatabase.cpp:54:0:
    2. kernel\/../drivers/mysql/qsql_mysql.h:108:33: error: expected ')' before '*' tok
    3. en
    4. mingw32-make[2]: *** [tmp/obj/release_static/qsqldatabase.o] Error 1
    5. mingw32-make[2]: Leaving directory `E:/Qt/2010.05/qt/src/sql'
    6. mingw32-make[1]: *** [release] Error 2
    7. mingw32-make[1]: Leaving directory `E:/Qt/2010.05/qt/src/sql'
    8. mingw32-make: *** [sub-sql-make_default-ordered] Error 2
    To copy to clipboard, switch view to plain text mode 

    Basing on this log I suppose that error is at line 108, but this line doesn't tell me much:
    Qt Code:
    1. Q_UNUSED(tc);
    To copy to clipboard, switch view to plain text mode 

    Is there anyone that could assist me with fixing this?

  2. #2
    Join Date
    May 2011
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compiling Qt with MySQL support on Windows 7 with MinGW.

    Quote Originally Posted by liprandi View Post
    Did you try to execute bin\qtvars.bat before to call configure and mingw32-make?
    I don't have such file in bin directory.

  4. #4
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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?

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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 ?

  6. #6
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Compiling Qt with MySQL support on Windows 7 with MinGW.

    Quote Originally Posted by ChrisW67 View Post
    Are you deliberately building a static version of Qt?
    Yes, I do.

    Quote Originally Posted by ChrisW67 View Post
    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 View Post
    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 View Post
    The MingW bundled in the Qt SDK, or another?
    Another one, the one I used previously (before I've installed Qt).
    It is:
    Qt Code:
    1. C:\Users\Tomek>mingw32-make -v
    2. GNU Make 3.82
    3. Built for i386-pc-mingw32
    4. Copyright (C) 2010 Free Software Foundation, Inc.
    5. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    6. This is free software: you are free to change and redistribute it.
    7. There is NO WARRANTY, to the extent permitted by law.
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by ChrisW67 View Post
    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 View Post
    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).

    Tried to follow these steps: http://www.qtcentre.org/threads/2397...551#post116551
    But still same output, here's my console session log:
    Qt Code:
    1. Setting up a MinGW/Qt only environment...
    2. -- QTDIR set to E:\Qt\4.7.3
    3. -- PATH set to E:\Qt\4.7.3\bin
    4. -- Adding D:\Services\MinGW\bin to PATH
    5. -- Adding C:\Windows\System32 to PATH
    6. -- QMAKESPEC set to win32-g++
    7.  
    8. E:\Qt\4.7.3>D:
    9.  
    10. D:\>cd services/mingw
    11.  
    12. D:\Services\MinGW>cd %QTDIR%/src/plugins/sqldrivers/mysql
    13.  
    14. D:\Services\MinGW>cd %QTDIR%/src/plugins/sqldrivers/mysql
    15.  
    16. D:\Services\MinGW>E:
    17.  
    18. E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=D:\Serv
    19. ices\MinGW\include" "LIBS+=D:\Services\MinGW\lib\libmysql.a" mysql.pro
    20. WARNING: (internal):1: Unescaped backslashes are deprecated.
    21. WARNING: (internal):1: Unescaped backslashes are deprecated.
    22. WARNING: (internal):1: Unescaped backslashes are deprecated.
    23.  
    24. E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>qmake -o Makefile "INCLUDEPATH+=D:\\Ser
    25. vices\\MinGW\\include" "LIBS+=D:\\Services\\MinGW\\lib\\libmysql.a" mysql.pro
    26.  
    27. E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>mingw32-make
    28. mingw32-make -f Makefile.Debug
    29. mingw32-make[1]: Entering directory `E:/Qt/4.7.3/src/plugins/sqldrivers/mysql'
    30. g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -
    31. DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_DLL -DQT_PLUGIN -DQT_SQL_LIB -
    32. DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_H
    33. AVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\..\..\include\QtCore" -I"..\..\..\..\inclu
    34. de\QtSql" -I"..\..\..\..\include" -I"d:\Services\MinGW\include" -I"..\..\..\..\i
    35. nclude\ActiveQt" -I"debug" -I"..\..\..\..\mkspecs\win32-g++" -o debug\main.o mai
    36. n.cpp
    37. In file included from main.cpp:44:0:
    38. ../../../sql/drivers/mysql/qsql_mysql.h:108:33: error: expected ')' before '*' t
    39. oken
    40. mingw32-make[1]: *** [debug/main.o] Error 1
    41. mingw32-make[1]: Leaving directory `E:/Qt/4.7.3/src/plugins/sqldrivers/mysql'
    42. mingw32-make: *** [debug] Error 2
    43.  
    44. E:\Qt\4.7.3\src\plugins\sqldrivers\mysql>
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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.

Similar Threads

  1. Replies: 1
    Last Post: 13th March 2011, 14:30
  2. Problems while compiling QT on Windows with MS VC2008 support
    By csantos in forum Installation and Deployment
    Replies: 2
    Last Post: 11th September 2010, 07:37
  3. Qt 4.4 on Windows with SSL support and MingW?
    By DerSchoeneBahnhof in forum Installation and Deployment
    Replies: 3
    Last Post: 2nd June 2008, 22:23
  4. Compiling qshortcutdialog on Windows with mingw
    By dvmorris in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2007, 19:16
  5. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.