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. Qt 5.10.0 building mysql driver on Windows
Forum Update on Monday, May 27th 2025

Qt 5.10.0 building mysql driver on Windows

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
mysql drivererrorlibrary not defwindows 10
14 Posts 3 Posters 9.4k 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.
  • E EagleWatch
    10 Feb 2018, 17:08

    @koahnig

    Thx for your reply.

    I'm using mingw32.

    So, I've tried with single forward slash, and the result is the same (Project ERROR: Library 'mysql' is not defined.).
    I also tried with a copy of mysql.pro and added the statement you suggested.

    The error is still the same.

    I don't know why the library 'mysql' cannot be used :(.

    K Offline
    K Offline
    koahnig
    wrote on 10 Feb 2018, 18:35 last edited by
    #4

    @EagleWatch

    You can add

    message("LIBS " $$LIBS)
    

    to get the output what you have actually in your LIBS statement. Are you sure that the path you are using is ok?

    Vote the answer(s) that helped you to solve your issue(s)

    E 1 Reply Last reply 10 Feb 2018, 21:13
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 10 Feb 2018, 18:40 last edited by
      #5

      Hi,

      IIRC, with the latest versions of Qt, you have to call qmake one level above first, and the in the folder of the driver you are interested in.

      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
      • K koahnig
        10 Feb 2018, 18:35

        @EagleWatch

        You can add

        message("LIBS " $$LIBS)
        

        to get the output what you have actually in your LIBS statement. Are you sure that the path you are using is ok?

        E Offline
        E Offline
        EagleWatch
        wrote on 10 Feb 2018, 21:13 last edited by EagleWatch 2 Nov 2018, 13:56
        #6

        @koahnig

        I can't execute the *.pro file since I have the error.
        The path I use is Mysql Server path. Should I use the C connector instead ?

        @SGaist

        I tried what you suggested, but It didn't work too :(.

        K 1 Reply Last reply 10 Feb 2018, 22:01
        0
        • E EagleWatch
          10 Feb 2018, 21:13

          @koahnig

          I can't execute the *.pro file since I have the error.
          The path I use is Mysql Server path. Should I use the C connector instead ?

          @SGaist

          I tried what you suggested, but It didn't work too :(.

          K Offline
          K Offline
          koahnig
          wrote on 10 Feb 2018, 22:01 last edited by
          #7

          @EagleWatch

          Are still using this follwing commands?

          set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.7
          qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" mysql.pro
          

          @koahnig said in Qt 5.10.0 building mysql driver on Windows:

          newmysql.pro

          TARGET = qsqlmysql
          
          INCLUDEPATH += <full path here>/include
          LIBS += -L<full path here>/lib
          LIBS+= -lmysql
          
          HEADERS += $$PWD/qsql_mysql_p.h
          SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
          
          QMAKE_USE += mysql
          
          OTHER_FILES += mysql.json
          
          PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
          include(../qsqldriverbase.pri)
          

          Note there are in LIBS statement prefixes "-L" and "-l" (uppcase and lowercase 'L')
          See for some details here

          This was meant as substitute of your previous mysql.pro

          You would have to use:

          qmake newmysql.pro
          

          However, you have to replace <full path here> with your actual full path.

          Vote the answer(s) that helped you to solve your issue(s)

          E 1 Reply Last reply 10 Feb 2018, 22:36
          0
          • K koahnig
            10 Feb 2018, 22:01

            @EagleWatch

            Are still using this follwing commands?

            set mysql=C:\\PROGRA~2\\MySQL\\MYSQLS~1.7
            qmake "INCLUDEPATH+=%mysql%\\include" "LIBS+=%mysql%\\lib\\libmysql.lib" mysql.pro
            

            @koahnig said in Qt 5.10.0 building mysql driver on Windows:

            newmysql.pro

            TARGET = qsqlmysql
            
            INCLUDEPATH += <full path here>/include
            LIBS += -L<full path here>/lib
            LIBS+= -lmysql
            
            HEADERS += $$PWD/qsql_mysql_p.h
            SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
            
            QMAKE_USE += mysql
            
            OTHER_FILES += mysql.json
            
            PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
            include(../qsqldriverbase.pri)
            

            Note there are in LIBS statement prefixes "-L" and "-l" (uppcase and lowercase 'L')
            See for some details here

            This was meant as substitute of your previous mysql.pro

            You would have to use:

            qmake newmysql.pro
            

            However, you have to replace <full path here> with your actual full path.

            E Offline
            E Offline
            EagleWatch
            wrote on 10 Feb 2018, 22:36 last edited by EagleWatch 2 Oct 2018, 22:51
            #8

            @koahnig

            No, I'm not using the first command anymore.

            I used :

            qmake newmysl.pro
            

            I had a mistake in message command, that's why it didn't work before.
            So, here is what I get now :

            Project MESSAGE: LIBS  -LC:\Program Files (x86)\MySQL\MySQL Server 5.7/lib -lmysql
            Project ERROR: Library 'mysql' is not defined.
            

            I have replaced <full path> with my path ;).

            K 1 Reply Last reply 10 Feb 2018, 23:10
            0
            • E EagleWatch
              10 Feb 2018, 22:36

              @koahnig

              No, I'm not using the first command anymore.

              I used :

              qmake newmysl.pro
              

              I had a mistake in message command, that's why it didn't work before.
              So, here is what I get now :

              Project MESSAGE: LIBS  -LC:\Program Files (x86)\MySQL\MySQL Server 5.7/lib -lmysql
              Project ERROR: Library 'mysql' is not defined.
              

              I have replaced <full path> with my path ;).

              K Offline
              K Offline
              koahnig
              wrote on 10 Feb 2018, 23:10 last edited by
              #9

              @EagleWatch

              OK, change to

              INCLUDEPATH += "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include"
              LIBS += -L"C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib"
              

              AFAIK qmake is not happy about backslashes. You use them only for continuation lines.

              Vote the answer(s) that helped you to solve your issue(s)

              E 1 Reply Last reply 10 Feb 2018, 23:23
              0
              • K koahnig
                10 Feb 2018, 23:10

                @EagleWatch

                OK, change to

                INCLUDEPATH += "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include"
                LIBS += -L"C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib"
                

                AFAIK qmake is not happy about backslashes. You use them only for continuation lines.

                E Offline
                E Offline
                EagleWatch
                wrote on 10 Feb 2018, 23:23 last edited by
                #10

                @koahnig

                Here is the result :

                Project MESSAGE: LIBS  -LC:/Program Files (x86)/MySQL/MySQL Server 5.7/lib -lmysql
                Project ERROR: Library 'mysql' is not defined.
                

                I've also tried to use the configure script with :

                configure -sql-mysql
                

                But the result was :

                Qt Sql:
                  DB2 (IBM) .............................. no
                  InterBase .............................. no
                  MySql .................................. no
                  OCI (Oracle) ........................... no
                  ODBC ................................... yes
                  PostgreSQL ............................. no
                  SQLite2 ................................ no
                  SQLite ................................. yes
                    Using system provided SQLite ......... no
                  TDS (Sybase) ........................... no
                

                It seems that mysql is no recognized :(.

                K 1 Reply Last reply 11 Feb 2018, 10:40
                0
                • E EagleWatch
                  10 Feb 2018, 23:23

                  @koahnig

                  Here is the result :

                  Project MESSAGE: LIBS  -LC:/Program Files (x86)/MySQL/MySQL Server 5.7/lib -lmysql
                  Project ERROR: Library 'mysql' is not defined.
                  

                  I've also tried to use the configure script with :

                  configure -sql-mysql
                  

                  But the result was :

                  Qt Sql:
                    DB2 (IBM) .............................. no
                    InterBase .............................. no
                    MySql .................................. no
                    OCI (Oracle) ........................... no
                    ODBC ................................... yes
                    PostgreSQL ............................. no
                    SQLite2 ................................ no
                    SQLite ................................. yes
                      Using system provided SQLite ......... no
                    TDS (Sybase) ........................... no
                  

                  It seems that mysql is no recognized :(.

                  K Offline
                  K Offline
                  koahnig
                  wrote on 11 Feb 2018, 10:40 last edited by koahnig 2 Nov 2018, 10:51
                  #11

                  @EagleWatch

                  Might be a stupid question, but are you a 100% positive that the library stump is really at that given location?

                  Also the INCLUDEPATH and LIBS statement in .pro file requires " because of the spaces in the path names. However, you can basically copy the folders "include" and "lib" into a folder without spaces. That gets you rid of the ambiguities with the proper syntax of using "

                  When copying the folders from "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include" to "c:/mysqltmp/include" and
                  "C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib" to "c:/mysqltmp/lib" for instance you can use

                  TARGET = qsqlmysql
                  
                  INCLUDEPATH += c:/mysqltmp/include
                  LIBS += -Lc:/mysqltmp/lib
                  LIBS += -lmysql
                  
                  HEADERS += $$PWD/qsql_mysql_p.h
                  SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
                  
                  QMAKE_USE += mysql
                  
                  OTHER_FILES += mysql.json
                  
                  PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
                  include(../qsqldriverbase.pri)
                  

                  Did you try to follow @SGaist 's advice?

                  Vote the answer(s) that helped you to solve your issue(s)

                  E 1 Reply Last reply 11 Feb 2018, 13:23
                  0
                  • K koahnig
                    11 Feb 2018, 10:40

                    @EagleWatch

                    Might be a stupid question, but are you a 100% positive that the library stump is really at that given location?

                    Also the INCLUDEPATH and LIBS statement in .pro file requires " because of the spaces in the path names. However, you can basically copy the folders "include" and "lib" into a folder without spaces. That gets you rid of the ambiguities with the proper syntax of using "

                    When copying the folders from "C:/Program Files (x86)/MySQL/MySQL Server 5.7/include" to "c:/mysqltmp/include" and
                    "C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib" to "c:/mysqltmp/lib" for instance you can use

                    TARGET = qsqlmysql
                    
                    INCLUDEPATH += c:/mysqltmp/include
                    LIBS += -Lc:/mysqltmp/lib
                    LIBS += -lmysql
                    
                    HEADERS += $$PWD/qsql_mysql_p.h
                    SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
                    
                    QMAKE_USE += mysql
                    
                    OTHER_FILES += mysql.json
                    
                    PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
                    include(../qsqldriverbase.pri)
                    

                    Did you try to follow @SGaist 's advice?

                    E Offline
                    E Offline
                    EagleWatch
                    wrote on 11 Feb 2018, 13:23 last edited by
                    #12

                    @koahnig

                    Yes, I'm pretty sure.
                    Just in case, you can see what are the libs in the path :

                    11/02/2018  13:42    <DIR>          .
                    11/02/2018  13:42    <DIR>          ..
                    09/12/2017  09:00         4 165 632 libmysql.dll
                    09/12/2017  09:00            27 538 libmysql.lib
                    09/12/2017  09:00        18 174 230 mysqlclient.lib
                    11/02/2018  13:42    <DIR>          plugin
                    

                    I tried to copy the include and libs folders into a folder without spaces (C:/mysql/include and C:/mysql/lib)
                    So I changed it in the newmysql.pro file.
                    However the error is still here.

                    I've removed completely my MySQL installation and installed a new one with the version 5.6.39 instead of version 5.7.21 because I've checked that Qt team has tested it on 5.6.11 (version I cannot find on the official mysql website).
                    But the error is still here.

                    I've followed @SGaist advice as mentionned below, but I've still the error :(.

                    Maybe I cannot build the MySQL plugin under Qt Version 5.10, so I've to change to another database ?

                    K 1 Reply Last reply 11 Feb 2018, 13:59
                    0
                    • E EagleWatch
                      11 Feb 2018, 13:23

                      @koahnig

                      Yes, I'm pretty sure.
                      Just in case, you can see what are the libs in the path :

                      11/02/2018  13:42    <DIR>          .
                      11/02/2018  13:42    <DIR>          ..
                      09/12/2017  09:00         4 165 632 libmysql.dll
                      09/12/2017  09:00            27 538 libmysql.lib
                      09/12/2017  09:00        18 174 230 mysqlclient.lib
                      11/02/2018  13:42    <DIR>          plugin
                      

                      I tried to copy the include and libs folders into a folder without spaces (C:/mysql/include and C:/mysql/lib)
                      So I changed it in the newmysql.pro file.
                      However the error is still here.

                      I've removed completely my MySQL installation and installed a new one with the version 5.6.39 instead of version 5.7.21 because I've checked that Qt team has tested it on 5.6.11 (version I cannot find on the official mysql website).
                      But the error is still here.

                      I've followed @SGaist advice as mentionned below, but I've still the error :(.

                      Maybe I cannot build the MySQL plugin under Qt Version 5.10, so I've to change to another database ?

                      K Offline
                      K Offline
                      koahnig
                      wrote on 11 Feb 2018, 13:59 last edited by
                      #13

                      @EagleWatch

                      Well the question is also if you have to build it all. With pre-builts it is included.

                      Vote the answer(s) that helped you to solve your issue(s)

                      E 1 Reply Last reply 11 Feb 2018, 14:16
                      0
                      • K koahnig
                        11 Feb 2018, 13:59

                        @EagleWatch

                        Well the question is also if you have to build it all. With pre-builts it is included.

                        E Offline
                        E Offline
                        EagleWatch
                        wrote on 11 Feb 2018, 14:16 last edited by
                        #14

                        @koahnig

                        You're right, I think I'll go for it.

                        Thx for your time et your help anyway.

                        1 Reply Last reply
                        0

                        13/14

                        11 Feb 2018, 13:59

                        • Login

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