Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Compile MySQL plugin for Qt
Forum Updated to NodeBB v4.3 + New Features

Compile MySQL plugin for Qt

Scheduled Pinned Locked Moved Installation and Deployment
11 Posts 3 Posters 8.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doobinay
    wrote on last edited by
    #1

    Hello,
    first, sorry about the topic 20mins ago, I messed up with the versions...
    I'll try to be as comprehensible as possible (I'm not a native english speaker).

    I just downloaded the SDK 1.1, with Qt Creator 2.1.
    Inside it, there is no MySQL driver; I know I have to compile it myself.

    My question is:
    Can't I compile this libmysql.a from the pack I just downloaded ? or do I have to download the Qt sources, compile them with the mysql options and all that just to get the libmysql.a.

    ps: I can't try "this":http://developer.qt.nokia.com/forums/viewthread/5698/, since there is no mysql.pro in the SDK 1.1

    [updated the title, Tobias]

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      As I said in the other thread, you need to rebuild Qt to enabled MySQL support. This is more easily done by downloading the stand-alone Qt source package rather than trying to rebuild the Qt that ships as part of the SDK.

      Go to "the download site":http://qt.nokia.com/downloads and from the right hand side labelled "Qt: Framework Only" and download the source for your platform and follow my instructions in the previous thread.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You can install the sources right from the SDK. Just start the Maintain Qt SDK application and choose to install the sources from there. You only need to compile the driver itself, not the whole of Qt.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          If you do it that way I think you will also need to install perl. The last time I checked the sources that shipped with the SDK did not have the camelcased headers generated and so the configure step tries to run the synqt perl script to create them.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • D Offline
            D Offline
            doobinay
            wrote on last edited by
            #5

            Ok thanks you two. This answer my question.

            I downloaded the sources using the Maintain Qt Application and installed PERL

            Following "this":http://www.rag.com.au/linux/qt4howto.html, I did this:
            @configure -platform win32-g++ -static -release -qt-sql-mysql -l mysql -I "C:\Program Files\MySQL\MySQL Server 5.5\include" -L "C:\Program Files\MySQL\MySQL Server 5.5\lib"@

            It seems to work but after, the mingw32-make command fails because of the space in the paths...

            @g++: Files\MySQL\MySQL: No such file or directory
            g++: Server: No such file or directory
            g++: 5.5\lib: No such file or directory@

            It's getting on my nerve, so I'll try again tomorrow...

            By the way, I'm recompiling the full Qt here, is there a way to recompile only the myqsl driver ?
            Thanks

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              What you can do, is create an "NTFS symlink or junction":http://en.wikipedia.org/wiki/NTFS_symbolic_link with a path that does not contain spaces, and use that path instead.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                Or in the future install MySQL (and other libs) to a location that does not have spaces in the path after being bitten by this many times before ;-)

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Meanwhile, I hope that at one point, the whole tool chain will be fixed so it simply accepts spaces in paths.

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    ZapB
                    wrote on last edited by
                    #9

                    Yes. You would hope this is simple in the 21st century. No such luck yet though.

                    Nokia Certified Qt Specialist
                    Interested in hearing about Qt related work

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      doobinay
                      wrote on last edited by
                      #10

                      Thanks a lot guys!
                      I finally made it after wasting 2 days to compile this MySQL driver.

                      At first I was compiling the whole sources... It took 3 hours each time.
                      Then I found that the Qt sources downloaded from the QT Maintain Application were not complete.
                      [...]
                      And after a big headache,
                      here is how I did it: (it might interest someone)

                      • Download Qt SDK and install (C:\QtSDK)
                      • Download mingw-utils and extract to C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin
                      • Put the C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin in the %PATH%
                      • Download Qt Sources and extract them (C:\QtSrc)
                      • Download and install a perl compiler (like ActivePERL)
                      • Install MySQL headers and libs in a path without spaces (C:\MySQL)

                      Open a Command Prompt
                      @set QTDIR=C:\QtSrc
                      set MYSQLDIR=C:\MySQL

                      cd %MYSQLDIR%\lib
                      reimp libmysql.lib
                      dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib %QTDIR%\src\plugins\sqldrivers\mysql\libmysql.a

                      cd %QTDIR%\src\plugins\sqldrivers\mysql
                      qmake -o Makefile "INCLUDEPATH+=%MYSQLDIR%\include" "LIBS+=%MYSQLDIR%\lib\liblibmysql.a" mysql.pro
                      mingw32-make@

                      Then copy libmysql.dll (from %MYSQLDIR%\lib) to any folder in the %PATH%
                      Copy %QTDIR%\plugins\sqldrivers\qsqlmysql4.dll & qsqlmysqld4.dll to C:\QtSDK\Desktop\Qt\4.7.3\mingw\plugins\sqldrivers

                      and it should be ok.

                      This seems so simple afterwards... =)

                      1 Reply Last reply
                      0
                      • Z Offline
                        Z Offline
                        ZapB
                        wrote on last edited by
                        #11

                        Glad you got it working. Good luck with the rest of your project.

                        Nokia Certified Qt Specialist
                        Interested in hearing about Qt related work

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved