Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to install MySql Driver?
Forum Updated to NodeBB v4.3 + New Features

How to install MySql Driver?

Scheduled Pinned Locked Moved General and Desktop
25 Posts 5 Posters 23.8k 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.
  • W Offline
    W Offline
    whitesong
    wrote on 10 Mar 2013, 06:35 last edited by
    #1

    It's about 3 days I'm working on install mysql driver but it hasn't worked. first i tested with xampp and didn't work, second i decided install mysql server but it didn't work either, i wrote this instructions in "Start>All Program>Qt SDK>Desktop>Qt 4.8.1 for Desktop (MinGW)"

    @cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 5.6\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 5.6\lib" mysql.pro
    make@

    but cmd show me 2 errors for example:

    @ make[1]: ***[tmp/obj/debug_shared/main.o] Error 1
    make[1]: leaving directory '/c/QtSDK/QtSources/4.8.1/src/plugins/sqldrivers/mysql'@

    I have no idea what i must to do. please tell me what must i do

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aklenczar
      wrote on 10 Mar 2013, 10:21 last edited by
      #2

      Maybe it will be helpful for you
      "Create MySQL driver for Qt5":http://seppemagiels.com/blog/create-mysql-driver-qt5-windows

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mohsen
        wrote on 10 Mar 2013, 13:03 last edited by
        #3
        • why do you use the path separator twice?
        • which compiler do you use? msvc or mingw?
        • have you read the "build instructions":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows?
        1 Reply Last reply
        0
        • W Offline
          W Offline
          whitesong
          wrote on 10 Mar 2013, 20:50 last edited by
          #4

          Thank you for your consideration. when I use single path separator show me this WARNING let me show the code in single separator:

          @C:\WINDOWS\system32>set mysql=C:\Program Files\MySQL\MySQL Server 5.6

          C:\WINDOWS\system32>cd C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql

          C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\Pro
          gram Files\MySQL\MySQL Server 5.6\include" "LIBS+=C:\Program Files\MySQL\MySQL S
          erver 5.6\lib\libmysql.lib" mysql.pro
          WARNING: (internal):1: Unescaped backslashes are deprecated.
          WARNING: (internal):1: Unescaped backslashes are deprecated.
          WARNING: (internal):1: Unescaped backslashes are deprecated.@

          and my compiler is MinGW also I've read "This link":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows
          @aklenczar my version is 4.8.1 and test your way but it didn't work and it shows the same error.
          by the way, i must say my OS is XP

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 11 Mar 2013, 09:03 last edited by
            #5

            Hi,

            Two things i can think of:

            1. you are missing a -L before your MySQL path in your LIBS statement
            2. Using spaces in lib path on windows has always been a problem (quoted or not, at least for me) I've always reverted to either having all paths without spaces or use the 8.3 names of the folders

            Hope it helps

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • W Offline
              W Offline
              whitesong
              wrote on 11 Mar 2013, 11:00 last edited by
              #6

              Hi SGaist.
              my 'libmysql.ilb' file is in this directory:
              C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib
              and my 'include' folder in this:
              C:\Program Files\MySQL\MySQL Server 5.6\include
              so
              I changed MySql path to this:

              @C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\PROGRA~1\MySQL\MYSQLS~1.6\include" "LIBS+=C:\PROGRA~1\MySQL\MYSQLS~1.6\LIB\LIBMYS~1.lib" mysql.pro@
              although this code show me the same Error, may be I wrote wrong 8.3 name.
              it's better to see if my path is correct or not

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 11 Mar 2013, 11:36 last edited by
                #7

                Just to be sure, what compiler are you using ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  whitesong
                  wrote on 11 Mar 2013, 15:30 last edited by
                  #8

                  OK. my compiler is MinGW

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 11 Mar 2013, 15:39 last edited by
                    #9

                    Then you have to follow that set of "instructions":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-mysql-driver-for-mingw-users

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      whitesong
                      wrote on 11 Mar 2013, 16:05 last edited by
                      #10

                      my compiler is installed with qt creator in default setting, do you think is necessary download MinGW in order to this instructions?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 11 Mar 2013, 16:06 last edited by
                        #11

                        No need to download another MinGW, use the one that came with Qt

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • W Offline
                          W Offline
                          whitesong
                          wrote on 12 Mar 2013, 06:35 last edited by
                          #12

                          I skip this part:
                          (Open the DOS prompt, go to C:\MySQL\MySQL51\lib\opt, and run the following commands:
                          reimp -d libmysql.lib
                          dlltool -k -d libmysql.def -l libmysql.a)
                          Because, it shows this message:

                          @C:\PROGRA~1\MySQL\MYSQLS~1.6\lib>reimp -d libmysql.lib
                          'reimp' is not recognized as an internal or external command,
                          operable program or batch file.@

                          also I don't have 'opt' folder, I just have 'C:\Program Files\MySQL\MySQL Server 5.6\lib\libmysql.lib'
                          Then, I wrote this part:
                          @C:\QtSDK\QTSOUR~1\4.8.1>configure.exe -debug-and-release -platform win32-g++ -qt
                          -sql-mysql -l mysql -I C:\PROGRA~1\MySQL\MYSQLS~1.6\include -L C:\PROGRA~1\
                          MySQL\MYSQLS~1.6\lib@
                          and after long time this error appeared:
                          @mingw32-make[2]: *** [../../lib/QtSqld4.dll] Error 1
                          mingw32-make[2]: Leaving directory c:/QtSDK/QTSOUR~1/4.8.1/src/sql' mingw32-make[1]: *** [debug-all] Error 2 mingw32-make[1]: Leaving directory c:/QtSDK/QTSOUR~1/4.8.1/src/sql'
                          mingw32-make: *** [sub-sql-sub_src_target_ordered] Error 2@

                          I think these error are for my version of Qt4.8.1 and mySql5.6 because these instructions are provided for MySql5.1 and Qt4.6.2, am I right?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 12 Mar 2013, 09:42 last edited by
                            #13

                            You need to install reimp for MinGW, the paths might have changed in between but the basics stay the same

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              whitesong
                              wrote on 12 Mar 2013, 11:34 last edited by
                              #14

                              oh you're right. But if I run
                              @reimp -d libmysql.lib@

                              will libmysql.def and libmysql.a be created?
                              Because I don't have them now in order to rest of the process.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 12 Mar 2013, 11:45 last edited by
                                #15

                                reimp to create libmysql.def
                                dlltool to create libmysql.a

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  mohsen
                                  wrote on 12 Mar 2013, 12:03 last edited by
                                  #16

                                  so you haven't followed the instructions carefully. all the steps mentioned by SGaist was completely described.

                                  1 Reply Last reply
                                  0
                                  • W Offline
                                    W Offline
                                    whitesong
                                    wrote on 12 Mar 2013, 12:39 last edited by
                                    #17

                                    this is the first time i hear about rimp

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mohsen
                                      wrote on 12 Mar 2013, 16:26 last edited by
                                      #18

                                      checkout http://www.qtexperts.ir/wiki/index.xhtml/ساخت_درایور_MySQL for build instructions in Persian

                                      1 Reply Last reply
                                      0
                                      • W Offline
                                        W Offline
                                        whitesong
                                        wrote on 14 Mar 2013, 06:44 last edited by
                                        #19

                                        I've done both of your ways, I succeeded to make libmysql.def and libmysql.a, Then I ran this code
                                        @C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\Program Files\MySQL\MySQL Server 5.6\include -L C:\Program Files\MySQL\MySQL Server 5.6\lib@
                                        (I used path with space because of -I and -L) after a while it shows many messages some of them is:

                                        @c:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug all
                                        mingw32-make[3]: Entering directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
                                        mingw32-make[3]: Nothing to be done for all'. mingw32-make[3]: Leaving directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
                                        c:/QtSDK/mingw/bin/mingw32-make -f Makefile.Release all
                                        mingw32-make[3]: Entering directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders' mingw32-make[3]: Nothing to be done for all'.
                                        mingw32-make[3]: Leaving directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders' mingw32-make[2]: Leaving directory c:/QtSDK/QtSources/4.8.1/src/imports/shaders'
                                        mingw32-make[1]: Leaving directory `c:/QtSDK/QtSources/4.8.1/src/imports'@
                                        i ignored them and ran next step
                                        @C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\PR
                                        OGRA~1\MySQL\MYSQLS~1.6\include" "LIBS+=-L. mysql" mysql.pro@

                                        and i saw no error, but mysql driver wasn't installed.
                                        i decided use Mohsen's method, with ran this method i have libqsqlmysql4.a
                                        libqsqlmysqld4.a
                                        qsqlmysql4.dll
                                        qsqlmysqld4.dll
                                        In "C:\QtSDK\QtSources\4.8.1\plugins\sqldrivers" i copied them to my project but when i run this code
                                        @qDebug() << QSqlDatabase::drivers();@
                                        i don't see qmysql driver

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          mohsen
                                          wrote on 14 Mar 2013, 10:04 last edited by
                                          #20
                                          • if you're running your application through QtCreator you won't need to copy them into your app dir. it's just enough having them in "C:\QtSDK\QtSources\4.8.1\plugins\sqldrivers" just making sure your other Qt libs are in "C:\QtSDK\QtSources\4.8.1\lib" and this is the path where you've defined in QTDIR. otherwise if this is only the path of sources directory then you must move the result binaries onto the main Qt directory path/plugins/sqldrivers.

                                          • if you're trying to make a release then you'll need to have qmysql.dll and libmysql.dll in "[YOUR EXE PATH]/sqldrivers/"

                                          1 Reply Last reply
                                          0

                                          6/25

                                          11 Mar 2013, 11:00

                                          19 unread
                                          • Login

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