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. How to setup MySQL with MSVC in Qt?
Forum Updated to NodeBB v4.3 + New Features

How to setup MySQL with MSVC in Qt?

Scheduled Pinned Locked Moved Solved Installation and Deployment
18 Posts 5 Posters 1.9k 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.
  • N Nima Ghorab

    @JonB and @SGaist Thank you for your helps so much!
    I try short path for MySQL too but it is not working yet!

    F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake MYSQL_INCDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\include MYSQL_LIBDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\lib
    
    F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>nmake sub-mysql
    
    Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            cd mysql\ && ( if not exist Makefile F:\Softwares\Qt\5.13.1\msvc2017_64\bin\qmake.exe -o Makefile F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro "MYSQL_INCDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\include" "MYSQL_LIBDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\lib" ) && c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile
    
    Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
            c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile.Release all
    
    Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    NMAKE : fatal error U1073: don't know how to make 'C:/Program\'
    Stop.
    NMAKE : fatal error U1077: 'c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    

    What can I do now?

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #9

    @Nima-Ghorab
    Other than asking @SGaist again, as I know nothing about this make process: it looks like the error comes during the "secondary" nmake invoked from
    c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile.Release all
    I would find which directory that takes place in, and look through its Makefile.Release file for anything it (or anything it "includes" (!include), and anything it references via $(SOMETHING) macros) for the string Program?

    Also, running nmake /d /p prints extra information about what it;s doing, from which you might be able to figure where the issue is. If you change your nmake command lines to include those options it would be good. Since I don't use qmake or nmake you'd have to find out how to do that, or someone here might be able to tell you.

    N 1 Reply Last reply
    1
    • JonBJ JonB

      @Nima-Ghorab
      Other than asking @SGaist again, as I know nothing about this make process: it looks like the error comes during the "secondary" nmake invoked from
      c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile.Release all
      I would find which directory that takes place in, and look through its Makefile.Release file for anything it (or anything it "includes" (!include), and anything it references via $(SOMETHING) macros) for the string Program?

      Also, running nmake /d /p prints extra information about what it;s doing, from which you might be able to figure where the issue is. If you change your nmake command lines to include those options it would be good. Since I don't use qmake or nmake you'd have to find out how to do that, or someone here might be able to tell you.

      N Offline
      N Offline
      Nima Ghorab
      wrote on last edited by
      #10

      Dear @JonB I am working on what you and @SGaist said...
      Yes the problem was in Makefile.Release!
      So after cleaning every file which generated with qmake command I can't find MySQL library even I address both include and lib folder in short form:

      F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\include MYSQL_LIBDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\lib
      Info: creating stash file F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
      
      Running configuration tests...
      Checking for DB2 (IBM)... no
      Checking for InterBase... no
      Checking for MySQL... no
      Checking for OCI (Oracle)... no
      Checking for ODBC... no
      Checking for PostgreSQL... no
      Checking for SQLite (version 2)... no
      Checking for TDS (Sybase)... no
      Done running configuration tests.
      
      Configure summary:
      
      Qt Sql Drivers:
        DB2 (IBM) .............................. no
        InterBase .............................. no
        MySql .................................. no
        OCI (Oracle) ........................... no
        ODBC ................................... no
        PostgreSQL ............................. no
        SQLite2 ................................ no
        SQLite ................................. yes
          Using system provided SQLite ......... no
        TDS (Sybase) ........................... no
      
      Qt is now configured for building. Just run 'nmake'.
      Once everything is built, you must run 'nmake install'.
      Qt will be installed into 'F:\Softwares\Qt\5.13.1\msvc2017_64'.
      
      Prior to reconfiguration, make sure you remove any leftovers from
      the previous build.
      

      Whatever I did it just tells MySQL .... no!
      If I use MinGW command line it will find it without any problem but in case of using MSVC this error happens!
      Can you point me to right direction?
      Thank you so much!

      jsulmJ 1 Reply Last reply
      0
      • N Nima Ghorab

        Dear @JonB I am working on what you and @SGaist said...
        Yes the problem was in Makefile.Release!
        So after cleaning every file which generated with qmake command I can't find MySQL library even I address both include and lib folder in short form:

        F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\include MYSQL_LIBDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\lib
        Info: creating stash file F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\.qmake.stash
        
        Running configuration tests...
        Checking for DB2 (IBM)... no
        Checking for InterBase... no
        Checking for MySQL... no
        Checking for OCI (Oracle)... no
        Checking for ODBC... no
        Checking for PostgreSQL... no
        Checking for SQLite (version 2)... no
        Checking for TDS (Sybase)... no
        Done running configuration tests.
        
        Configure summary:
        
        Qt Sql Drivers:
          DB2 (IBM) .............................. no
          InterBase .............................. no
          MySql .................................. no
          OCI (Oracle) ........................... no
          ODBC ................................... no
          PostgreSQL ............................. no
          SQLite2 ................................ no
          SQLite ................................. yes
            Using system provided SQLite ......... no
          TDS (Sybase) ........................... no
        
        Qt is now configured for building. Just run 'nmake'.
        Once everything is built, you must run 'nmake install'.
        Qt will be installed into 'F:\Softwares\Qt\5.13.1\msvc2017_64'.
        
        Prior to reconfiguration, make sure you remove any leftovers from
        the previous build.
        

        Whatever I did it just tells MySQL .... no!
        If I use MinGW command line it will find it without any problem but in case of using MSVC this error happens!
        Can you point me to right direction?
        Thank you so much!

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #11

        @Nima-Ghorab said in How to setup MySQL with MSVC in Qt?:

        Can you point me to right direction?

        Please check the configure log file - you will find there the information why MySQL wasn't enabled (probably missing MySQL client libraries and header files).

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

        N 1 Reply Last reply
        1
        • jsulmJ jsulm

          @Nima-Ghorab said in How to setup MySQL with MSVC in Qt?:

          Can you point me to right direction?

          Please check the configure log file - you will find there the information why MySQL wasn't enabled (probably missing MySQL client libraries and header files).

          N Offline
          N Offline
          Nima Ghorab
          wrote on last edited by
          #12

          Dear @jsulm really thanks!
          here is the log file:

          Command line: "MYSQL_INCDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\include" "MYSQL_LIBDIR=c:\PROGRA~1\MySQL\MYSQLS~1.0\lib"
          Global lib dirs: [C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\lib C:\\Utils\\postgresql\\pgsql\\lib] []
          Global inc dirs: [C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\include C:\\Utils\\postgresql\\pgsql\\include] []
          looking for library db2
          Trying source 0 (type inline) of library db2 ...
          None of [db2cli.lib] found in [] and global paths.
            => source produced no result.
          Trying source 1 (type inline) of library db2 ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.db2 FAILED
          looking for library ibase
          Trying source 0 (type inline) of library ibase ...
          None of [gds32_ms.lib] found in [] and global paths.
            => source produced no result.
          Trying source 1 (type inline) of library ibase ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.ibase FAILED
          looking for library mysql
          Trying source 0 (type mysqlConfig) of library mysql ...
          mysql_config not found.
            => source produced no result.
          Trying source 1 (type mysqlConfig) of library mysql ...
          mysql_config not found.
            => source produced no result.
          Trying source 2 (type mysqlConfig) of library mysql ...
          mysql_config not found.
            => source produced no result.
          Trying source 3 (type mysqlConfig) of library mysql ...
          mysql_config not found.
            => source produced no result.
          Trying source 4 (type inline) of library mysql ...
            => source failed condition '!config.win32'.
          Trying source 5 (type inline) of library mysql ...
          + cd /d F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && F:\Softwares\Qt\5.13.1\msvc2017_64\bin\qmake.exe "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" "QMAKE_LIBDIR += C:\\openssl\\lib C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\lib C:\\Utils\\postgresql\\pgsql\\lib" "INCLUDEPATH += C:\\openssl\\include C:\\Utils\\my_sql\\mysql-5.7.25-winx64\\include C:\\Utils\\postgresql\\pgsql\\include" "QMAKE_USE += mysql" "QMAKE_LIBS_MYSQL = c:\\PROGRA~1\\MySQL\\MYSQLS~1.0\\lib/libmysql.lib" "QMAKE_INCDIR_MYSQL = c:\\PROGRA~1\\MySQL\\MYSQLS~1.0\\include" F:/Softwares/Qt/5.13.1/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
          > Info: creating stash file F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\config.tests\.qmake.stash
          + cd /d F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\config.tests\mysql && set MAKEFLAGS=& nmake
          > Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
          > Copyright (C) Microsoft Corporation.  All rights reserved.
          > 	cl -c -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -W0 -EHsc -DUNICODE -D_UNICODE -DWIN32 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -DWIN64 -DNDEBUG -I. -IC:\openssl\include -IC:\Utils\my_sql\mysql-5.7.25-winx64\include -IC:\Utils\postgresql\pgsql\include -Ic:\PROGRA~1\MySQL\MYSQLS~1.0\include -IF:\Softwares\Qt\5.13.1\msvc2017_64\mkspecs\win32-msvc -Fo @C:\Users\Nima\AppData\Local\Temp\nm359E.tmp
          > main.cpp
          > .\main.cpp(3): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
          > NMAKE : fatal error U1077: 'c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\cl.EXE' : return code '0x2'
          > Stop.
           => source failed verification.
          Trying source 6 (type inline) of library mysql ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.mysql FAILED
          looking for library oci
          Trying source 0 (type inline) of library oci ...
          None of [oci.lib] found in [] and global paths.
            => source produced no result.
          Trying source 1 (type inline) of library oci ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.oci FAILED
          looking for library odbc
          Trying source 0 (type inline) of library odbc ...
          None of [odbc32.lib] found in [] and global paths.
            => source produced no result.
          Trying source 1 (type inline) of library odbc ...
            => source failed condition 'config.darwin'.
          Trying source 2 (type inline) of library odbc ...
            => source failed condition '!config.win32 && !config.darwin'.
          test config.sqldrivers.libraries.odbc FAILED
          looking for library psql
          Trying source 0 (type pkgConfig) of library psql ...
          pkg-config use disabled globally.
            => source produced no result.
          Trying source 1 (type psqlConfig) of library psql ...
          pg_config not found.
            => source produced no result.
          Trying source 2 (type psqlEnv) of library psql ...
          None of [libpq.lib] found in [] and global paths.
          None of [ws2_32.lib] found in [] and global paths.
          None of [advapi32.lib] found in [] and global paths.
            => source produced no result.
          Trying source 3 (type psqlEnv) of library psql ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.psql FAILED
          looking for library sqlite2
          Trying source 0 (type inline) of library sqlite2 ...
          None of [sqlite.lib] found in [] and global paths.
            => source produced no result.
          test config.sqldrivers.libraries.sqlite2 FAILED
          looking for library tds
          Trying source 0 (type sybaseEnv) of library tds ...
          None of [NTWDBLIB.lib] found in [] and global paths.
            => source produced no result.
          Trying source 1 (type sybaseEnv) of library tds ...
            => source failed condition '!config.win32'.
          test config.sqldrivers.libraries.tds FAILED
          

          I now see the errors but I don't know how can I fix these errors!
          Any help would be greatly appreciated!

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

            Not finding windows.h ? That's pretty surprising.
            How did you setup that command prompt before trying to build the plugin ?

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

            N 1 Reply Last reply
            2
            • SGaistS SGaist

              Not finding windows.h ? That's pretty surprising.
              How did you setup that command prompt before trying to build the plugin ?

              N Offline
              N Offline
              Nima Ghorab
              wrote on last edited by Nima Ghorab
              #14

              Dear @SGaist I used Qt 5.13.1 (MSVC 2017 64-bit) console.
              It can't find 64-bit MSVC compiler on my machine so I have to add it in path environment variable.
              And know it just can't find header files and I have to add all include folders in include environment variable.
              In Qt creator IDE I don't have any problem with MSVCs at all but in the case of consoles I don't know why it can't find MSVCs on my machine!
              I installed Microsoft Build Tools 2017 - 15.9.16 version in default location C:\Program File (x86)...

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

                Usually you either have somewhere shortcuts that will start a command prompt with the Visual Studio setup done for you. See here for information about that.

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

                N 1 Reply Last reply
                1
                • SGaistS SGaist

                  Usually you either have somewhere shortcuts that will start a command prompt with the Visual Studio setup done for you. See here for information about that.

                  N Offline
                  N Offline
                  Nima Ghorab
                  wrote on last edited by
                  #16

                  Dear @SGaist after I used Microsoft default command line instead of Qt console everything compile successfully with out any errors.
                  God bless you and everyone which helped me!

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

                    Great !

                    Happy coding ! :-)

                    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
                    • N Nima Ghorab

                      Hello guys!
                      I want to setup MySQL with MSVC in Qt but without success!
                      The problem is when I want to build MySQL driver via Qt 5.13.1 (MSVC 2017 b4-bit) console, it gives me error!
                      I enter following commands:

                      cd F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers
                      
                      qmake MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
                      
                      nmake sub-mysql
                      

                      After running last command I get this error:

                      Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
                      Copyright (C) Microsoft Corporation.  All rights reserved.
                      
                              cd mysql\ && ( if not exist Makefile F:\Softwares\Qt\5.13.1\msvc2017_64\bin\qmake.exe -o Makefile F:\Softwares\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers\mysql\mysql.pro "MYSQL_INCDIR=C:\Program Files\MySQL\MySQL Server 8.0\include" "MYSQL_LIBDIR=C:\Program Files\MySQL\MySQL Server 8.0\lib" ) && c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile
                      
                      Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
                      Copyright (C) Microsoft Corporation.  All rights reserved.
                      
                              c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe -f Makefile.Release all
                      
                      Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
                      Copyright (C) Microsoft Corporation.  All rights reserved.
                      
                      NMAKE : fatal error U1073: don't know how to make 'C:/Program\'
                      Stop.
                      NMAKE : fatal error U1077: 'c:\PROGRA~2\MICROS~1\2017\BUILDT~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\X64\nmake.exe' : return code '0x2'
                      Stop.
                      NMAKE : fatal error U1077: 'cd' : return code '0x2'
                      Stop.
                      

                      I used short path but problem isn't solve yet!
                      Can anyone help me to build MySQL via MSVC for Qt?
                      Really thanks!

                      C Offline
                      C Offline
                      cawlfj
                      wrote on last edited by
                      #18

                      @Nima-Ghorab hi Could you help to list all steps that you used like as which version of mysql (best list address you dowload)
                      which openssl ( if need download it) which comply line command .
                      Many thanks for your 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