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. Library 'mysql' is not defined
QtWS25 Last Chance

Library 'mysql' is not defined

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 6 Posters 7.6k 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.
  • H Offline
    H Offline
    hobbyProgrammer
    wrote on 26 Nov 2019, 20:07 last edited by hobbyProgrammer
    #1

    Hi,
    I know that there are a lot of people who already asked almost everything there is about the MySQL driver.
    I think I've tried it all, but I keep getting the message "project ERROR: Library 'mysql' is not defined.

    Is there anyone who can help me?

    I tried to follow the instructions multiple times, but failed every time.
    I use mingw73_32 and Qt 5.13.2

    When I get this error?

    set mysql=C:\\MySQL\\MySQL~Server~5.5
    cd C:\Qt\Qt5.13.2\5.13.2\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" -o Makefile mysql.pro
    

    I get:

    Project ERROR: Library 'mysql' is not defined
    

    I had a look around and qtsqldrivers-config.pri is in that directory.

    J K 2 Replies Last reply 26 Nov 2019, 21:16
    0
    • H Offline
      H Offline
      hobbyProgrammer
      wrote on 5 Dec 2019, 14:17 last edited by
      #22

      This worked for me and I used:

      • OS: Windows
      • Qt version: 5.13.1 and 5.13.2
      • Qt creator: 4.10.1
      • compiler: mingw73_32

      Step by step:

      1. Download msys & msysgit
      2. Open the cmd of msys and type these commands (keep in mind that the second and third command do not contain cd. You need to call the .exe files from the mysql path):
      • cd <path to libmysql.lib>
      • C:/msysgit/mingw/bin/reimp.exe libmysql.lib
      • C:/msysgit/mingw/bin/dlltool.exe -k -d libmysql.def -l libmysql.a
      1. go to the qt cmd called: Qt <version> (<compiler>). Use the one with the mingw32 compiler.
      2. execute the following commands:
      • cd C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers
      • qmake sqldrivers.pro
      1. open mysql.pro and make sure that it looks like this (change the include path and the lib path, but make sure that the include path and the depend path are the same!) and save after you finished editing it:
      TARGET = qsqlmysql
      
      HEADERS += $$PWD/qsql_mysql_p.h
      SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
      
      #QMAKE_USE += mysql
      LIBS += -L'C:/MySQL/lib/'
      -llibmysql
      
      INCLUDEPATH += 'C:/MySQL/include'
      
      DEPENDPATH += 'C:/MySQL/include'
      
      
      OTHER_FILES += mysql.json
      
      PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
      include(../qsqldriverbase.pri)
      
      
      1. execute the following commands:
      • qmake mysql.pro
      • qmake "INCLUDEPATH+=<includepath>" "LIBS+=<libpath>/libmysql.lib" mysql.pro
      • mingw32-make
      1. go to C:/Qt/Qt<version>/<version>/Src/qtbase/src/plugins/sqldrivers/plugins/sqldrivers in the file explorer. You should see these four files now:
      • qsqlmysql.dll
      • qsqlmysqld.dll
      • qsqlmysql.a
      • qsqlmysqld.a
      1. copy them and place them into: C:/Qt/Qt<version>/<version>/mingw73_32/plugins/sqldrivers
      1 Reply Last reply
      1
      • H hobbyProgrammer
        26 Nov 2019, 20:07

        Hi,
        I know that there are a lot of people who already asked almost everything there is about the MySQL driver.
        I think I've tried it all, but I keep getting the message "project ERROR: Library 'mysql' is not defined.

        Is there anyone who can help me?

        I tried to follow the instructions multiple times, but failed every time.
        I use mingw73_32 and Qt 5.13.2

        When I get this error?

        set mysql=C:\\MySQL\\MySQL~Server~5.5
        cd C:\Qt\Qt5.13.2\5.13.2\qtbase\src\plugins\sqldrivers\mysql
        qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" -o Makefile mysql.pro
        

        I get:

        Project ERROR: Library 'mysql' is not defined
        

        I had a look around and qtsqldrivers-config.pri is in that directory.

        J Offline
        J Offline
        JonB
        wrote on 26 Nov 2019, 21:16 last edited by JonB
        #2

        @hobbyProgrammer
        I would worry about the first error message, maybe the second is a consequence of it.

        Cannot read C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory

        I had a look around and qtsqldrivers-config.pri is in that directory.

        I would investigate this a bit more.

        Otherwise, have you Googled specifically for Project ERROR: Library 'mysql' is not defined, there are a number of hits?

        H 1 Reply Last reply 27 Nov 2019, 06:44
        0
        • J JonB
          26 Nov 2019, 21:16

          @hobbyProgrammer
          I would worry about the first error message, maybe the second is a consequence of it.

          Cannot read C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory

          I had a look around and qtsqldrivers-config.pri is in that directory.

          I would investigate this a bit more.

          Otherwise, have you Googled specifically for Project ERROR: Library 'mysql' is not defined, there are a number of hits?

          H Offline
          H Offline
          hobbyProgrammer
          wrote on 27 Nov 2019, 06:44 last edited by
          #3

          @JonB hi, I already fixed the first error, but the second one stays. I also have that one on my laptop (abd computer). For the past 2 weeks I've been googling it, but so far without result.

          1 Reply Last reply
          0
          • H hobbyProgrammer
            26 Nov 2019, 20:07

            Hi,
            I know that there are a lot of people who already asked almost everything there is about the MySQL driver.
            I think I've tried it all, but I keep getting the message "project ERROR: Library 'mysql' is not defined.

            Is there anyone who can help me?

            I tried to follow the instructions multiple times, but failed every time.
            I use mingw73_32 and Qt 5.13.2

            When I get this error?

            set mysql=C:\\MySQL\\MySQL~Server~5.5
            cd C:\Qt\Qt5.13.2\5.13.2\qtbase\src\plugins\sqldrivers\mysql
            qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" -o Makefile mysql.pro
            

            I get:

            Project ERROR: Library 'mysql' is not defined
            

            I had a look around and qtsqldrivers-config.pri is in that directory.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 27 Nov 2019, 08:57 last edited by
            #4

            @hobbyProgrammer said in Library 'mysql' is not defined:

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

            qmake uses $$(...) for environment variables, this isn't cmd, do you should try like this:

            qmake "INCLUDEPATH+=$$(mysql)/\include" "LIBS+=$$(mysql)/lib/libmysql.lib" -o Makefile mysql.pro
            

            Read and abide by the Qt Code of Conduct

            H 1 Reply Last reply 27 Nov 2019, 09:02
            0
            • K kshegunov
              27 Nov 2019, 08:57

              @hobbyProgrammer said in Library 'mysql' is not defined:

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

              qmake uses $$(...) for environment variables, this isn't cmd, do you should try like this:

              qmake "INCLUDEPATH+=$$(mysql)/\include" "LIBS+=$$(mysql)/lib/libmysql.lib" -o Makefile mysql.pro
              
              H Offline
              H Offline
              hobbyProgrammer
              wrote on 27 Nov 2019, 09:02 last edited by
              #5

              @kshegunov Thanks, but I still get the same error.

              K 1 Reply Last reply 27 Nov 2019, 09:08
              0
              • H Offline
                H Offline
                hobbyProgrammer
                wrote on 27 Nov 2019, 09:04 last edited by
                #6

                also whenever i open sqldrivers.pro it gives me the same errors:

                Project ERROR: Could not find feature sql-mysql.
                [Inexact] Project ERROR: Library 'db2' is not defined.
                [Inexact] Project ERROR: Library 'oci' is not defined.
                [Inexact] Project ERROR: Library 'mysql' is not defined.
                [Inexact] Project ERROR: Library 'ibase' is not defined.
                [Inexact] Project ERROR: Library 'psql' is not defined.
                [Inexact] Project ERROR: Library 'odbc' is not defined.
                [Inexact] Project ERROR: Library 'sqlite2' is not defined.
                [Inexact] Project ERROR: Library 'tds' is not defined.

                1 Reply Last reply
                0
                • H hobbyProgrammer
                  27 Nov 2019, 09:02

                  @kshegunov Thanks, but I still get the same error.

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 27 Nov 2019, 09:08 last edited by kshegunov
                  #7

                  Why do you have tilde in your path?
                  Make sure that you get the correct paths inside the project file (use message() to print them out). Also the qmake run can be made more verbose if you pass -d to it (-d -d for max verbosity).

                  also whenever i open sqldrivers.pro it gives me the same errors:

                  Well, don't. Not unless you intend to build all the drivers.

                  Read and abide by the Qt Code of Conduct

                  H 1 Reply Last reply 27 Nov 2019, 10:26
                  2
                  • K kshegunov
                    27 Nov 2019, 09:08

                    Why do you have tilde in your path?
                    Make sure that you get the correct paths inside the project file (use message() to print them out). Also the qmake run can be made more verbose if you pass -d to it (-d -d for max verbosity).

                    also whenever i open sqldrivers.pro it gives me the same errors:

                    Well, don't. Not unless you intend to build all the drivers.

                    H Offline
                    H Offline
                    hobbyProgrammer
                    wrote on 27 Nov 2019, 10:26 last edited by
                    #8

                    @kshegunov Hi
                    Where exactly do I need to add message()?
                    In the main.cpp?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 27 Nov 2019, 10:36 last edited by
                      #9

                      Hi,

                      Looks like you are following the old instructions.

                      Take a look at the current Qt MySQL driver documentation. The parameters have changed.

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

                      H 1 Reply Last reply 27 Nov 2019, 10:40
                      0
                      • SGaistS SGaist
                        27 Nov 2019, 10:36

                        Hi,

                        Looks like you are following the old instructions.

                        Take a look at the current Qt MySQL driver documentation. The parameters have changed.

                        H Offline
                        H Offline
                        hobbyProgrammer
                        wrote on 27 Nov 2019, 10:40 last edited by hobbyProgrammer
                        #10

                        @SGaist yes, but unfortunately, following the new instructions results in
                        Project ERROR: Could not find feature sql-mysql

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 27 Nov 2019, 10:55 last edited by
                          #11

                          Based on your first post you are missing two dashes after the qmake call. The example from the documentation shows qmake -- and then the additional stuff. Please try that.

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

                          H 2 Replies Last reply 27 Nov 2019, 10:59
                          0
                          • SGaistS SGaist
                            27 Nov 2019, 10:55

                            Based on your first post you are missing two dashes after the qmake call. The example from the documentation shows qmake -- and then the additional stuff. Please try that.

                            H Offline
                            H Offline
                            hobbyProgrammer
                            wrote on 27 Nov 2019, 10:59 last edited by
                            #12

                            @SGaist so like:
                            qmake -- MYSQL_INCDIR=:C\MySQL\include "MYSQL_LIBDIR=C:\MySQL\lib"

                            H 1 Reply Last reply 27 Nov 2019, 11:00
                            0
                            • H hobbyProgrammer
                              27 Nov 2019, 10:59

                              @SGaist so like:
                              qmake -- MYSQL_INCDIR=:C\MySQL\include "MYSQL_LIBDIR=C:\MySQL\lib"

                              H Offline
                              H Offline
                              hobbyProgrammer
                              wrote on 27 Nov 2019, 11:00 last edited by
                              #13
                              This post is deleted!
                              H 1 Reply Last reply 27 Nov 2019, 11:03
                              0
                              • H hobbyProgrammer
                                27 Nov 2019, 11:00

                                This post is deleted!

                                H Offline
                                H Offline
                                hobbyProgrammer
                                wrote on 27 Nov 2019, 11:03 last edited by
                                #14
                                This post is deleted!
                                1 Reply Last reply
                                0
                                • SGaistS SGaist
                                  27 Nov 2019, 10:55

                                  Based on your first post you are missing two dashes after the qmake call. The example from the documentation shows qmake -- and then the additional stuff. Please try that.

                                  H Offline
                                  H Offline
                                  hobbyProgrammer
                                  wrote on 4 Dec 2019, 10:54 last edited by hobbyProgrammer 12 Apr 2019, 10:54
                                  #15

                                  @SGaist I tried that, but it still won't work. I also do not get the configuration screen where you can see which drivers are installed. Only when I do mingw32-make I see that it only goes to odbc and sqlite

                                  C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=:C\MySQL\include MYSQL_LIBDIR=C:\MySQL\lib
                                  
                                  C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make
                                  cd odbc\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\odbc\odbc.pro ) && mingw32-make -f Makefile
                                  mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  mingw32-make -f Makefile.Release all
                                  mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  mingw32-make[2]: Nothing to be done for 'all'.
                                  mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  mingw32-make -f Makefile.Debug all
                                  mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  mingw32-make[2]: Nothing to be done for 'all'.
                                  mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                  cd sqlite\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && mingw32-make -f Makefile
                                  mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  mingw32-make -f Makefile.Release all
                                  mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  mingw32-make[2]: Nothing to be done for 'all'.
                                  mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  mingw32-make -f Makefile.Debug all
                                  mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  mingw32-make[2]: Nothing to be done for 'all'.
                                  mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                  

                                  Also this doesn't seem to work:

                                  C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make sub-mysql
                                  mingw32-make: *** No rule to make target 'sub-mysql'.  Stop.
                                  
                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 4 Dec 2019, 19:45 last edited by
                                    #16

                                    You still have typos in your paths.

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

                                    H 1 Reply Last reply 5 Dec 2019, 07:55
                                    1
                                    • SGaistS SGaist
                                      4 Dec 2019, 19:45

                                      You still have typos in your paths.

                                      H Offline
                                      H Offline
                                      hobbyProgrammer
                                      wrote on 5 Dec 2019, 07:55 last edited by
                                      #17

                                      @SGaist in the mysql_incdir/mysql_libdir? or anywhere else?

                                      jsulmJ 1 Reply Last reply 5 Dec 2019, 08:16
                                      0
                                      • H hobbyProgrammer
                                        5 Dec 2019, 07:55

                                        @SGaist in the mysql_incdir/mysql_libdir? or anywhere else?

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 5 Dec 2019, 08:16 last edited by
                                        #18

                                        @hobbyProgrammer Please check better what you're writing:

                                        MYSQL_INCDIR=:C\MySQL
                                        

                                        Why is there a : ?

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        H 1 Reply Last reply 5 Dec 2019, 09:58
                                        0
                                        • jsulmJ jsulm
                                          5 Dec 2019, 08:16

                                          @hobbyProgrammer Please check better what you're writing:

                                          MYSQL_INCDIR=:C\MySQL
                                          

                                          Why is there a : ?

                                          H Offline
                                          H Offline
                                          hobbyProgrammer
                                          wrote on 5 Dec 2019, 09:58 last edited by
                                          #19

                                          @jsulm hi,

                                          yes I see. I tried again without the typo but it still didn't work

                                          C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=C:\MySQL\include MYSQL_LIBDIR=C:\MySQL\lib
                                          
                                          C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers>mingw32-make
                                          cd odbc\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\odbc\odbc.pro ) && mingw32-make -f Makefile
                                          mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          mingw32-make -f Makefile.Release all
                                          mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          mingw32-make[2]: Nothing to be done for 'all'.
                                          mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          mingw32-make -f Makefile.Debug all
                                          mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          mingw32-make[2]: Nothing to be done for 'all'.
                                          mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/odbc'
                                          cd sqlite\ && ( if not exist Makefile C:\Qt\Qt5.13.2\5.13.2\mingw73_32\bin\qmake.exe -o Makefile C:\Qt\Qt5.13.2\5.13.2\Src\qtbase\src\plugins\sqldrivers\sqlite\sqlite.pro ) && mingw32-make -f Makefile
                                          mingw32-make[1]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          mingw32-make -f Makefile.Release all
                                          mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          mingw32-make[2]: Nothing to be done for 'all'.
                                          mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          mingw32-make -f Makefile.Debug all
                                          mingw32-make[2]: Entering directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          mingw32-make[2]: Nothing to be done for 'all'.
                                          mingw32-make[2]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.13.2/5.13.2/Src/qtbase/src/plugins/sqldrivers/sqlite'
                                          
                                          

                                          for some reason it just doesn't go to mysql

                                          1 Reply Last reply
                                          0
                                          • Christian EhrlicherC Offline
                                            Christian EhrlicherC Offline
                                            Christian Ehrlicher
                                            Lifetime Qt Champion
                                            wrote on 5 Dec 2019, 11:27 last edited by
                                            #20

                                            Since qmake did not output anything according to your logs you should remove config.cache and start over (already told you above somewhere)

                                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                            Visit the Qt Academy at https://academy.qt.io/catalog

                                            H 1 Reply Last reply 5 Dec 2019, 13:59
                                            1

                                            • Login

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