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. [SOLVED]Trying to build mysql driver in Qt 5.1.0 and MySQL 5.6
Qt 6.11 is out! See what's new in the release blog

[SOLVED]Trying to build mysql driver in Qt 5.1.0 and MySQL 5.6

Scheduled Pinned Locked Moved Installation and Deployment
38 Posts 9 Posters 43.6k Views 3 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #7

    Little correction, you don't need the MySQL sources, the standard package should contain the libs and includes.

    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
    • francescmmF Offline
      francescmmF Offline
      francescmm
      wrote on last edited by
      #8

      Thanks you! :)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koresaram777
        wrote on last edited by
        #9

        [quote author="francescmm" date="1373443489"]Hi!

        As SGalst has said you is that you must download the Qt sources. In addition, you must download the source code of MySQL from its webpage.

        The next step is to open the mysql.pro, add the following lines:

        @LIBS += mysql/path/lib/libmysql.lib
        INCLUDEPATH += mysql/path/include@

        Then, you onyle have to compile in debug mode and in release mode. It provide you two files (I don't remember the exactly name) in both cases: [libqsqlmysqld.a, qsqlmysqld.dll] and [libqsqlmysql.a, qsqlmysql4.dll].

        You have to copy them into the sqldrivers dir of Qt non-source path.[/quote]

        when i am trying to make a mysql.pro by command "mingw32-make" it show me a lot of mistakes like: undefined reference to 'mysql_num_rows@4' and something like that.

        after all it says:
        c:/qt/qt5.1.0/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: .obj/release_shared/qsql_mysql.o: bad reloc address 0x4 in section `.data'
        collect2.exe: error: ld returned 1 exit status
        Makefile.Release:80: recipe for target '........\plugins\sqldrivers\qsqlmysql.dll' failed
        mingw32-make[1]: *** [........\plugins\sqldrivers\qsqlmysql.dll] Error 1
        mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.0/5.1.0/Src/qtbase/src/plugins/sqldrivers/mysql'
        makefile:38: recipe for target 'release-all' failed
        mingw32-make: *** [release-all] Error 2

        1 Reply Last reply
        0
        • francescmmF Offline
          francescmmF Offline
          francescmm
          wrote on last edited by
          #10

          It is because the folder you are including in both INCLUDEPATH and LIBS have not the necessary CPP files. Are you sure you have all the sources?

          Try downloading: "MySQL Connector":http://dev.mysql.com/downloads/connector/c/

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koresaram777
            wrote on last edited by
            #11

            [quote author="francescmm" date="1373465557"]It is because the folder you are including in both INCLUDEPATH and LIBS have not the necessary CPP files. Are you sure you have all the sources?

            Try downloading: "MySQL Connector":http://dev.mysql.com/downloads/connector/c/[/quote]

            yes, I am sure that i have all sources, should I setup environment variables???
            may be it is because i have win8 x64 but my mingw x32 and qt5.1.0 x32???

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koresaram777
              wrote on last edited by
              #12

              Thanks very much everybody! The problem is solved :)

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #13

                Great !

                Then don't forget to update the thread's title to solved, so other forum users may know a solution has been found :)

                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
                • VinorcolaV Offline
                  VinorcolaV Offline
                  Vinorcola
                  wrote on last edited by
                  #14

                  Hello,

                  It would have been nice to tell us how you solved your problem koresaram777.

                  Indeed, I follow every indication, download the C connector sources archives and then the C++ one, but still, I can't compile the plugin. There is no C++ file into those archive (only headers files).

                  I did some research but every time I have got a topic that says a different way. And I always still have those error messages:

                  undefined references to mysql_num_rows@4, mysql_stmt_num_rows@4, etc.

                  My computer is a 32bits so I only used (and download) the tools for 32bits. I say that because main of forum topic says that the problème come when using 64bits sources when the installed version of MySQL is 32bits.

                  If someone can help me. Thanks.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    koresaram777
                    wrote on last edited by
                    #15

                    [quote author="Vinorcola" date="1380787942"]Hello,

                    It would have been nice to tell us how you solved your problem koresaram777.

                    Indeed, I follow every indication, download the C connector sources archives and then the C++ one, but still, I can't compile the plugin. There is no C++ file into those archive (only headers files).

                    I did some research but every time I have got a topic that says a different way. And I always still have those error messages:

                    undefined references to mysql_num_rows@4, mysql_stmt_num_rows@4, etc.

                    My computer is a 32bits so I only used (and download) the tools for 32bits. I say that because main of forum topic says that the problème come when using 64bits sources when the installed version of MySQL is 32bits.

                    If someone can help me. Thanks.[/quote]

                    when you download the c connector, you need to install it, after installation create the empty folder in c disk, after this just copy all you files from C:\Program Files\MySQL\Connector C++\ to your new folder, and rename this folder for example mySQL, but do it without spaces. and aflter that when you compile reference to that folder which you created before and that's all :)

                    1 Reply Last reply
                    0
                    • VinorcolaV Offline
                      VinorcolaV Offline
                      Vinorcola
                      wrote on last edited by
                      #16

                      I did what you said, but have still have the same error. Can someone help me? Or send me the compile plugin?

                      Thanks

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koresaram777
                        wrote on last edited by
                        #17

                        [quote author="Vinorcola" date="1380803548"]I did what you said, but have still have the same error. Can someone help me? Or send me the compile plugin?

                        Thanks[/quote]

                        give your email and what qt version do you have?

                        1 Reply Last reply
                        0
                        • ? Offline
                          ? Offline
                          A Former User
                          wrote on last edited by
                          #18

                          Hi,

                          I've got some problems to compile Mysql driver, is something obvious for you ?

                          @cd C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\src\plugins\sqldrivers\mysql

                          set mysql="C:\\PROGRA~1\\MySQL\\MYSQLS~1.6"

                          qmake "INCLUDEPATH+=%mysql%\include\" "LIBS += -L %mysql%\lib\libmysql.lib" -o Makefile mysql.pro

                          mingw32-make@

                          @g++ -Wl,-s -shared -Wl,--out-implib,C:\Qt\Qt5.1.1\5.1.1\Src\qtbase\plugins\sqldr
                          ivers\libqsqlmysql.a -o ........\plugins\sqldrivers\qsqlmysql.dll .obj/releas
                          e_shared/main.o .obj/release_shared/qsql_mysql.o .obj/release_shared/moc_qsql_my
                          sql_p.o -llibmysql -LC:\Qt\Qt5.1.1\5.1.1\mingw48_32\lib -lQt5Sql -lQt5Core
                          c:/qt/qt5.1.1/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../..
                          /i686-w64-mingw32/bin/ld.exe: cannot find -llibmysql
                          collect2.exe: error: ld returned 1 exit status
                          Makefile.Release:80: recipe for target '........\plugins\sqldrivers\qsqlmysql
                          .dll' failed
                          mingw32-make[1]: *** [........\plugins\sqldrivers\qsqlmysql.dll] Error 1
                          mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.1.1/5.1.1/Src/qtbase/src/plugins/s
                          qldrivers/mysql'
                          makefile:38: recipe for target 'release-all' failed
                          mingw32-make: *** [release-all] Error 2@

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #19

                            @ "LIBS += -L %mysql%\lib\libmysql.lib"@

                            That's your problem, -L is to give a path not a library name

                            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
                            • ? Offline
                              ? Offline
                              A Former User
                              wrote on last edited by
                              #20

                              Thanks for your post's!

                              I got an issue if I want to build my driver. I'm using qt 5.3 and mysql 5.6 (mysql-5.6.20-win32).

                              I added mysql.pro to qt creator and add the following two lines to the .pro file:

                              @
                              LIBS += C:/mysql/mysql-5.6.20-win32lib/libmysql.lib
                              INCLUDEPATH += C:/mysql/mysql-5.6.20-win32/include
                              @

                              I got the following errors if i want to compile the mysql project:

                              C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'fd'

                              C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht untersttzt.

                              C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C2146: Syntaxfehler: Fehlendes ';' vor Bezeichner 'fd'

                              C:\mysql\mysql-5.6.20-win32\include\mysql_com.h:320: error: C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht untersttzt.

                              C:\work\build\qt5\qtbase\src\sql\drivers\mysql\qsql_mysql.cpp:44: error: C1083: Datei (Include) kann nicht ge”ffnet werden: "QtSql/private/qsqldriver_p.h": No such file or directory

                              Many thanks for your help!

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #21

                                Hi and welcome to devnet,

                                Did you first build Qt 5 yourself ?

                                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
                                • ? Offline
                                  ? Offline
                                  A Former User
                                  wrote on last edited by
                                  #22

                                  Hi SGaist,

                                  yes I built qt5 by my self. I also tried to build the drivers with the following commands (see http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows):

                                  cd C:\work\build\qt5\qtbase\src\plugins\sqldrivers\mysql

                                  qmake "INCLUDEPATH+=C:\mysql\mysql-5.6.20-win32\include" "LIBS+=C:\mysql\mysql-5.6.20-win32\lib\libmysql.lib" mysql.pro

                                  mingw32-make

                                  If I do the "mingw32-make" command I got the following errors:

                                  C:\work\build\qt5\qtbase\src\plugins\sqldrivers\mysql>mingw32-make
                                  mingw32-make -f Makefile.Release all
                                  mingw32-make[1]: Entering directory 'C:/work/build/qt5/qtbase/src/plugins/sqldri
                                  vers/mysql'
                                  Makefile.Release:65: *** missing separator. Stop.
                                  mingw32-make[1]: Leaving directory 'C:/work/build/qt5/qtbase/src/plugins/sqldriv
                                  ers/mysql'
                                  mingw32-make[1]: Leaving directory 'C:/work/build/qt5/qtbase/src/plugins/sqldriv
                                  ers/mysql'
                                  Makefile:40: recipe for target 'release-all' failed
                                  mingw32-make: *** [release-all] Error 2

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #23

                                    You're on windows either escape the backslashes or since you are using Qt use the unix notation i.e. forward slashes

                                    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
                                    • ? Offline
                                      ? Offline
                                      A Former User
                                      wrote on last edited by
                                      #24

                                      I'm working on a windows machine. You can see in my post that I'm setting the INCLUDEPATH and the LIBS with \

                                      What means this error exactly:

                                      Makefile.Release:65: *** missing separator. Stop.

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #25

                                        I know you are, and I already wrote the options you have:

                                        • escape the \ so in practice use \
                                        • Since you are using Qt use /

                                        Second option is cleaner.

                                        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
                                        • ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on last edited by
                                          #26

                                          Sorry for that stupid questions. I'm using the QT 5.4.0 64-bit for Desktop (MSVC 2013) command line.

                                          I got the same errors if I'm setting the paths like:

                                          qmake "INCLUDEPATH+=C:\mysql\mysql-5.6.20-win32\include" "LIBS+=C:\mysql\mysql-5.6.20-win32\lib\libmysql.lib" mysql.pro

                                          or:

                                          qmake "INCLUDEPATH+=C:/mysql/mysql-5.6.20-win32/include" "LIBS+=C:/mysql/mysql-5.6.20-win32/lib/libmysql.lib" mysql.pro

                                          or does it mean that I have to set the slashes in the Makefile.Release instead of \ to /

                                          Many thanks.

                                          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