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 create the plugin of MYSQL for Qt
Forum Update on Monday, May 27th 2025

How to create the plugin of MYSQL for Qt

Scheduled Pinned Locked Moved General and Desktop
33 Posts 17 Posters 38.8k Views
  • 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.
  • B Offline
    B Offline
    BlackStar
    wrote on 24 Apr 2014, 19:37 last edited by kshegunov
    #1

    Hi, having just solved the problem, i want to share how i managed to do it, and i have to admit that it was really painfull ^^

    1. Download : the mingw utilities here, and MySQL community server from the official site.

    2. Once you download the mingw utilities extract it, and then go to the bin directory, and copy everything to the bin directory of Qt, I copied it into : C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin, find a similar reference, once you do, install MySQL in C:\, once it's done, name the directory MySQL to simplify your life for the coming.

    3. Now that you have everything set, open the Qt DOS prompt it should be installed, I have Win8 so i have a link to it, at the home screen.

    4. Type this command : cd C:\MYSQL\lib, then : reimp libmysql.dll, then : dlltool -k -d libmysql.def -l libmysql.a.

    5. Now type : cd C:\Qt\Qt5.2.0\5.2.0\Src\qtbase, then type : configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\MySQL\MySQL51\include -L C:\MySQL\MySQL51\lib\opt
      you will have to wait for a long time, so go drink something. Then type mingw32-make sub-src.

    6. Now type : cd C:\Qt\Qt5.2.0\5.2.0\Src\qtbase\src\plugins\sqldrivers\mysql,
      and qmake "INCLUDEPATH+=C:/MySQL/include" "LIBS+=C:/MYSQL/lib//libmysql.lib" mysql.pro.

    7. Finally : mingw32-make

    After that you will have 4 new Files in C:\Qt\Qt5.2.0\5.2.0\Src\qtbase\plugins\sqldrivers
    wich are :

    • libqsqlmysql.a
    • libqsqlmysqld.a
    • qsqlmysql.dll
    • qsqlmysqld.dll

    Congratulations now so that Qt Creator recognize them, put them at C:\Qt\Qt5.2.0\Tools\QtCreator\bin\plugins\sqldrivers, and put it in the bin directory

    Note : I assume that you have installed Qt in C:\ , i have done the default installation so if you did the same, you want find any problem, and it's the Qt version with the mingw

    Hope it will help you, and be careful in naming your driver in the code of your application, it is QMYSQL.

    [Topic has been locked as a general information source. If you still have problems start a new thread on the boards! ~kshegunov]
    [Formatting was updated ~kshegunov]

    1 Reply Last reply
    8
    • Q Offline
      Q Offline
      qxoz
      wrote on 25 Apr 2014, 05:30 last edited by
      #2

      That's great!
      Thank you BlackStar for sharing this solution :)

      1 Reply Last reply
      2
      • B Offline
        B Offline
        BlackStar
        wrote on 26 Apr 2014, 11:10 last edited by
        #3

        ^^ you are very welcome

        1 Reply Last reply
        1
        • P Offline
          P Offline
          pmoglaikar
          wrote on 30 Apr 2014, 12:23 last edited by
          #4

          I must say that's really a painfull task.
          which you make some sort of easy thank BlackStar ! Nicely explain !!!

          1 Reply Last reply
          1
          • B Offline
            B Offline
            BlackStar
            wrote on 2 May 2014, 19:48 last edited by
            #5

            Thanks ^^ !

            1 Reply Last reply
            1
            • C Offline
              C Offline
              creatron
              wrote on 5 Jun 2014, 18:27 last edited by
              #6

              Maria dBase is free, and is mostly compatible with Mysql, and is shipped with most Linux distribution, why can't this be included in the box standard Qt, it would save many a lot of frustration, as we have to do-it every time we 'upgrade', because of license issues. For the guy who really needs MySql could do-it this , but for the other 98% a Maria driver should be fine. Does any one knows why Maria driver could not be shipped with Qt?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Suraj Golliwar
                wrote on 13 Jun 2014, 03:22 last edited by
                #7

                This is Awesome....Great Job..BlackStar.

                1 Reply Last reply
                1
                • B Offline
                  B Offline
                  bhupathyap
                  wrote on 21 Jul 2014, 05:39 last edited by
                  #8

                  How to create on for linux (ubuntu)? Pls Help......

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    euclidQt
                    wrote on 1 Aug 2014, 14:03 last edited by
                    #9

                    Does that work for OS X 10.9

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 2 Aug 2014, 21:48 last edited by
                      #10

                      Hi both,

                      Like written in the post, these instructions are for Windows. Linux and OS X are far less problematic. On OS X install mysql through e.g. macports with sudo port install mysql56 and on Linux, install the mysql dev packages.

                      For the rest just follow Qt's Sql Driver documentation

                      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
                      4
                      • K Offline
                        K Offline
                        kshots
                        wrote on 20 Aug 2014, 18:19 last edited by
                        #11

                        I recently ran into an issue with mysql (mariadb) in a linux environment - apparently, the 5.3.1 release ties to an older version of mysql that my system no longer supports (apparently, qt-5.3.1-release wants version .16, while my system uses .18). If you have this problem, an ldd of /path/to/qt5/plugins/sqldrivers/libqsqlmysql.so should show that it can't find your mysql libs. To fix this, go into the source directory at qtbase/src/plugins/sqldrivers/mysql, run qmake (specifically for 5.3.1, not the system qmake), and then make install.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          arsinte_andrei
                          wrote on 21 Aug 2014, 21:23 last edited by
                          #12

                          Even today Qt doesn't have a MySql proper plugin delivered with? any way.. thanks for this great job... that save me a lot of trouble I wish to do something similar with HeidiSql and this was a good start point.. Thanks again

                          1 Reply Last reply
                          0
                          • B Offline
                            B Offline
                            BlackStar
                            wrote on 4 Sept 2014, 11:11 last edited by
                            #13

                            You're all welcome :), for the guys who are asking for linux or Os X, but i don't know :(, try to fetch the doc.

                            1 Reply Last reply
                            1
                            • D Offline
                              D Offline
                              danny36
                              wrote on 29 Oct 2014, 11:54 last edited by
                              #14

                              Hello, I'm new to QT and I have installed QT from this installer on Windows 7 64bit:
                              qt-opensource-windows-x86-1.6.0-5-online.exe

                              but I don't see the src folder and I don't have a QT Sdk. How can I install the sdk? thanks.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 29 Oct 2014, 23:47 last edited by
                                #15

                                Hi and welcome to devnet,

                                You need to first install the sources. Use the installer for that

                                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
                                • D Offline
                                  D Offline
                                  danny36
                                  wrote on 30 Oct 2014, 08:12 last edited by
                                  #16

                                  OK now I have installed the sources (maybe) and I have a folder called Src, this is my path: C:\Qt\5.3\Src.

                                  I try to follow the tutorial but in my situation when prompt "reimp libmysql.dll" I receive this message:

                                  "reimp: libmysql.dll: invalid or corrupt import library"

                                  but if prompt "reimp libmysql.lib" seems to work.

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    danny36
                                    wrote on 30 Oct 2014, 09:48 last edited by
                                    #17

                                    now I'm arrived to step 5 but I think I have some problem, this is the ouput after lunch the command:

                                    configure.exe -debug-and-release -platform win32-g++ -qt-sql-mysql -l mysql -I C:\mysql\include -L C:\mysql\lib

                                    Creating qmake...
                                    mingw32-make: Nothing to be done for 'first'.
                                    Running configuration tests...
                                    g++: error: CreateProcess: No such file or directory
                                    mingw32-make: *** [arch.o] Error 1
                                    Could not find output file: No such file or directory
                                    WARNING: The DirectX SDK could not be detected:
                                    There is no Direct X SDK installed or the environment variable "DXSDK_DIR" is
                                    not set.
                                    Disabling the ANGLE backend.

                                    WARNING: Using OpenGL ES 2.0 without ANGLE.
                                    Specify -opengl desktop to use Open GL.
                                    The build will most likely fail.

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 31 Oct 2014, 00:04 last edited by
                                      #18

                                      Either install the Direct X SDK or pass -opengl desktop to configure

                                      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
                                      • D Offline
                                        D Offline
                                        danny36
                                        wrote on 31 Oct 2014, 08:41 last edited by
                                        #19

                                        I'm sorry and frustrated but
                                        but unfortunately for me it is the first time with C++ and QT.
                                        I lunch configure:

                                        configure.exe -opengl desktop

                                        and the result is:

                                        g++ -c -o qlibraryinfo.o -DUNICODE -ffunction-sections -g -IC:\Qt\5.3\Src\qtbas
                                        e/qmake -IC:\Qt\5.3\Src\qtbase/qmake/library -IC:\Qt\5.3\Src\qtbase/qmake/genera
                                        tors -IC:\Qt\5.3\Src\qtbase/qmake/generators/unix -IC:\Qt\5.3\Src\qtbase/qmake/g
                                        enerators/win32 -IC:\Qt\5.3\Src\qtbase/qmake/generators/mac -IC:\Qt\5.3\Src\qtba
                                        se/qmake/generators/integrity -IC:\Qt\5.3\Src\qtbase\include -IC:\Qt\5.3\Src\qtb
                                        ase\include/QtCore -IC:\Qt\5.3\Src\qtbase\include/QtCore/5.3.2 -IC:\Qt\5.3\Src\q
                                        tbase\include/QtCore/5.3.2/QtCore -IC:\Qt\5.3\Src\qtbase/src/corelib/global -DHA
                                        VE_QCONFIG_CPP -IC:\Qt\5.3\Src\qtbase\mkspecs\win32-g++ -IC:\Qt\5.3\Src\qtbase/t
                                        ools/shared -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_TEXTC
                                        ODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQ
                                        T_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_CRYPTOGRAPHICHASH_ONLY
                                        SHA1 -DQT_JSON_READONLY C:\Qt\5.3\Src\qtbase/src/corelib/global/qlibraryinfo.cp
                                        p
                                        g++: error: CreateProcess: No such file or directory
                                        Makefile:275: recipe for target 'qlibraryinfo.o' failed
                                        mingw32-make: *** [qlibraryinfo.o] Error 1
                                        rm -f project.o option.o property.o main.o ioutils.o proitems.o qmakevfs.o qmake
                                        globals.o qmakeparser.o qmakeevaluator.o qmakebuiltins.o makefile.o unixmake2.o
                                        unixmake.o mingw_make.o winmakefile.o projectgenerator.o meta.o makefiledeps.o m
                                        etamakefile.o xmloutput.o pbuilder_pbx.o msvc_vcproj.o msvc_vcxproj.o msvc_nmake
                                        .o msvc_objectmodel.o msbuild_objectmodel.o gbuild.o cesdkhandler.o qtextcodec.o
                                        qutfcodec.o qstring.o qstring_compat.o qstringbuilder.o qtextstream.o qiodevice
                                        .o qmalloc.o qglobal.o qarraydata.o qbytearray.o qbytearraymatcher.o qdatastream
                                        .o qbuffer.o qlist.o qfiledevice.o qfile.o qfilesystementry.o qfilesystemengine.
                                        o qfsfileengine.o qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.
                                        o qdiriterator.o quuid.o qhash.o qfileinfo.o qdatetime.o qstringlist.o qabstract
                                        fileengine.o qtemporaryfile.o qmap.o qmetatype.o qsettings.o qsystemerror.o qlib
                                        raryinfo.o qvariant.o qvsnprintf.o qlocale.o qlocale_tools.o qlinkedlist.o qnume
                                        ric.o qcryptographichash.o qxmlstream.o qxmlutils.o qlogging.o qjson.o qjsondocument.o qjsonparser.o qjsonarray.o qjsonobject.o qjsonvalue.o qfilesystemengine_w
                                        in.o qfilesystemiterator_win.o qfsfileengine_win.o qlocale_win.o qsettings_win.o
                                        qsystemlibrary.o registry.o
                                        g++ -c -o project.o -DUNICODE -ffunction-sections -g -IC:\Qt\5.3\Src\qtbase/qma
                                        ke -IC:\Qt\5.3\Src\qtbase/qmake/library -IC:\Qt\5.3\Src\qtbase/qmake/generators
                                        -IC:\Qt\5.3\Src\qtbase/qmake/generators/unix -IC:\Qt\5.3\Src\qtbase/qmake/genera
                                        tors/win32 -IC:\Qt\5.3\Src\qtbase/qmake/generators/mac -IC:\Qt\5.3\Src\qtbase/qm
                                        ake/generators/integrity -IC:\Qt\5.3\Src\qtbase\include -IC:\Qt\5.3\Src\qtbase\i
                                        nclude/QtCore -IC:\Qt\5.3\Src\qtbase\include/QtCore/5.3.2 -IC:\Qt\5.3\Src\qtbase
                                        \include/QtCore/5.3.2/QtCore -IC:\Qt\5.3\Src\qtbase/src/corelib/global -DHAVE_QC
                                        ONFIG_CPP -IC:\Qt\5.3\Src\qtbase\mkspecs\win32-g++ -IC:\Qt\5.3\Src\qtbase/tools/
                                        shared -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL -DQT_NO_TEXTCODEC
                                        -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO

                                        QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1
                                        -DQT_JSON_READONLY C:\Qt\5.3\Src\qtbase/qmake/project.cpp
                                        g++: error: CreateProcess:* No such file or directory*
                                        Makefile:196: recipe for target 'project.o' failed
                                        mingw32-make: *** [project.o] Error 1
                                        Building qmake failed, return code 2

                                        1 Reply Last reply
                                        1
                                        • S Offline
                                          S Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 1 Nov 2014, 00:11 last edited by
                                          #20

                                          Just one question, do you only need to build the MySQL plugin ? If so, there's no need to rebuild Qt completely

                                          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

                                          • Login

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