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 24.3k 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 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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 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 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 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 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 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
                    • W Offline
                      W Offline
                      whitesong
                      wrote on last edited by
                      #21

                      Ok, but there are many files in my “C:\QtSDK\QtSources\4.8.1\lib”, and in my path/plugins/sqldrivers these files exist:(libqsqlite4.a, libqsqlited4.a, libqsqlmysql4.a, libqsqlmysqld4.a, qsqlite4.dll, qsqlited4.dll, libqsqlmysql4.a, qsqlmysqld4.dll) and empty 'mysql' folder.
                      are those enough?
                      I need to say i just serch 'QMYSQLDriver' then i find it in few directories:
                      C:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtSql
                      C:\QtSDK\Desktop\Qt\4.8.1\mingw\include\QtSql
                      C:\QtSDK\QtSources\4.8.1\include\QtSql
                      C:\QtSDK\Simulator\Qt\mingw\include\QtSql
                      can I use them? how do I use them?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mohsen
                        wrote on last edited by
                        #22

                        however Qt keeps binary compatibility but it's better to use plugins built with same version. I can't further help you making that plugin available in your project since i don't know how Qt's configured and defined on your system.
                        i just can point you to review the path of Qt version in use both on Environment Variables/QTDIR and QtCreator/options/build&run/Qt Versions once again.

                        1 Reply Last reply
                        0
                        • W Offline
                          W Offline
                          whitesong
                          wrote on last edited by
                          #23

                          ok thanks all of you.

                          1 Reply Last reply
                          0
                          • Q Offline
                            Q Offline
                            quinhox5
                            wrote on last edited by
                            #24

                            Hey guys, i'm having a similar problem and my context is very similar.

                            I'm trying to compile the mysql driver using qt5 and mysqlserver 5.6, using mingw too and tryed to follow the tutorial "here":http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows. I did the reimp sucessfully creating the libmysql.a, i used the configure command sucessfully, but got an error trying to compile using mingw32-make sub-src. The errors are undefined references when trying to compile the mysql module.

                            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"

                            mingw32-make sub-src
                            @mingw32-make[3]: Entering directory 'C:/Users/Hugo/Downloads/qt-everywhere-opensource-src-5.0.1/qtbase/src/sql'
                            g++ -shared -Wl,--out-implib,C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\lib\libQt5Sqld.a -o ....\lib\Qt5Sqld.dll object_script.Qt5Sqld.Debug -lmysql -LC:/PROGRA~1/MySQL/MYSQLS
                            ~1.6/LIB -LC:/Users/Hugo/Downloads/qt-everywhere-opensource-src-5.0.1/qtbase/lib -lQt5Cored .obj\debug_shared\Qt5Sqld_resource_res.o
                            ./.obj\debug_shared\qsql_mysql.o: In function codec': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:223: undefined reference to mysql_character_set_name@4'
                            ./.obj\debug_shared\qsql_mysql.o: In function qMakeError': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:234: undefined reference to mysql_error@4'
                            C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:237: undefined reference to mysql_errno@4' ./.obj\debug_shared\qsql_mysql.o: In function qMakeStmtError':
                            C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:309: undefined reference to mysql_stmt_error@4' C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:312: undefined reference to mysql_stmt_errno@4'
                            ./.obj\debug_shared\qsql_mysql.o: In function ZN19QMYSQLResultPrivate12bindInValuesEv': C:\Users\Hugo\Downloads\qt-everywhere-opensource-src-5.0.1\qtbase\src\sql/drivers/mysql/qsql_mysql.cpp:358: undefined reference to mysql_stmt_result_metadata@4'
                            @

                            1 Reply Last reply
                            0
                            • Q Offline
                              Q Offline
                              quinhox5
                              wrote on last edited by
                              #25

                              Anyone?

                              I guess my problem is with the reimp not generating a usable libmysql.a, when i use the reimp in the mingw-utils0.3 i got the output just fine, but all the procedures as i described before fail. When downloading the last version of mingw-utils(0.4) i try to use de reimp but it says libmysql.lib is corrupted or something... so i guess this is where the problem come from.

                              Any thoughts? help?

                              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