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 Qt 6.5 mysql driver with cmake?
QtWS25 Last Chance

How to create Qt 6.5 mysql driver with cmake?

Scheduled Pinned Locked Moved Unsolved General and Desktop
60 Posts 8 Posters 8.7k 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.
  • S Saad02
    8 Jul 2023, 09:39

    I am really tired of trying to create driver again and again from instructions of stack overflow, yt videos, github , qt official site for about 1 to 1.5 months 😭😭😭
    Please! Please! Provide a fresh instruction to do it.

    I have installed qt 6.5.1 fully also the necessary mysql libraries.

    I have tried these kits below with build type Release:
    Desktop Qt 6.5.1 MSVC2019 64bit
    Desktop Qt 6.5.11 MSVC2019 64bit
    Desktop (x86-windows-msys-pe-64bit)

    From Qt creator-
    issues:
    F:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers\mysql\CMakeLists.txt:8: error: Unknown CMake command "qt_internal_add_plugin".
    :-1: error: CMake process exited with exit code 1.
    :-1: error: CMake project configuration failed. No CMake configuration for build type "Release" found.

    General Messages:
    Running F:\Qt\Tools\CMake_64\bin\cmake.exe -S F:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/mysql -B F:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/build-mysql-Desktop_Qt_6_5_1_MSVC2019_64bit-Release in F:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers\build-mysql-Desktop_Qt_6_5_1_MSVC2019_64bit-Release.
    CMake Warning (dev) in CMakeLists.txt:
    No project() command is present. The top-level CMakeLists.txt file must
    contain a literal, direct call to the project() command. Add a line of
    code such as

    project(ProjectName)
    

    near the top of the file, but after cmake_minimum_required().

    CMake is pretending there is a "project(Project)" command on the first
    line.
    This warning is for project developers. Use -Wno-dev to suppress it.

    CMake Error at CMakeLists.txt:8 (qt_internal_add_plugin):
    Unknown CMake command "qt_internal_add_plugin".

    CMake Warning (dev) in CMakeLists.txt:
    No cmake_minimum_required command is present. A line of code such as

    cmake_minimum_required(VERSION 3.24)
    

    should be added at the top of the file. The version specified may be lower
    if you wish to support older CMake versions for this project. For more
    information run "cmake --help-policy CMP0000".
    This warning is for project developers. Use -Wno-dev to suppress it.

    -- Configuring incomplete, errors occurred!
    See also "F:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/build-mysql-Desktop_Qt_6_5_1_MSVC2019_64bit-Release/CMakeFiles/CMakeOutput.log".
    CMake process exited with exit code 1.

    Elapsed time: 00:00.

    S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 8 Jul 2023, 10:06 last edited by
    #2

    Hi,

    Just follow the instructions of the documentation. Don't try to be fancy.

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

    S 1 Reply Last reply 8 Jul 2023, 10:55
    1
    • C Christian Ehrlicher moved this topic from Qt Creator and other tools on 8 Jul 2023, 10:42
    • S SGaist
      8 Jul 2023, 10:06

      Hi,

      Just follow the instructions of the documentation. Don't try to be fancy.

      S Offline
      S Offline
      Saad02
      wrote on 8 Jul 2023, 10:55 last edited by
      #3

      @SGaist Sir, I tried it several times and now again-

      Code:
      mkdir build-sqldrivers01
      cd build-sqldrivers01

      qt-cmake -G Ninja <qt_installation_path>\C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path><platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib"
      cmake --build .
      cmake --install .

      Result:
      The system cannot find the file specified.

      I ran this code on Qt 6.5.1 (MinGW 11.2.0 64-bit). I assure that this include path and the lib file is also valid.

      S 1 Reply Last reply 8 Jul 2023, 11:14
      0
      • S Saad02
        8 Jul 2023, 10:55

        @SGaist Sir, I tried it several times and now again-

        Code:
        mkdir build-sqldrivers01
        cd build-sqldrivers01

        qt-cmake -G Ninja <qt_installation_path>\C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path><platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib"
        cmake --build .
        cmake --install .

        Result:
        The system cannot find the file specified.

        I ran this code on Qt 6.5.1 (MinGW 11.2.0 64-bit). I assure that this include path and the lib file is also valid.

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Jul 2023, 11:14 last edited by
        #4

        You do realise that the values between "<>" are to be replaced and not copy pasted as is ?

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

        S 1 Reply Last reply 8 Jul 2023, 11:45
        1
        • S SGaist
          8 Jul 2023, 11:14

          You do realise that the values between "<>" are to be replaced and not copy pasted as is ?

          S Offline
          S Offline
          Saad02
          wrote on 8 Jul 2023, 11:45 last edited by
          #5

          @SGaist Yeah, I replaced it wisely. Can I provide you the ss of directories to assure you that directories are valid?

          S 1 Reply Last reply 8 Jul 2023, 11:48
          0
          • S Saad02
            8 Jul 2023, 11:45

            @SGaist Yeah, I replaced it wisely. Can I provide you the ss of directories to assure you that directories are valid?

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 8 Jul 2023, 11:48 last edited by
            #6

            Then please show the real command and arguments you used for cmake.

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

            S 1 Reply Last reply 8 Jul 2023, 11:55
            0
            • S SGaist
              8 Jul 2023, 11:48

              Then please show the real command and arguments you used for cmake.

              S Offline
              S Offline
              Saad02
              wrote on 8 Jul 2023, 11:55 last edited by
              #7

              @SGaist 1fc3ff25-ce7b-4f48-9a70-2baba4c3560d-image.png
              (I can't even solve this problem in hest as this site keeps me waiting for 600 seconds after every comment😭)

              C 1 Reply Last reply 8 Jul 2023, 12:57
              0
              • S Saad02
                8 Jul 2023, 11:55

                @SGaist 1fc3ff25-ce7b-4f48-9a70-2baba4c3560d-image.png
                (I can't even solve this problem in hest as this site keeps me waiting for 600 seconds after every comment😭)

                C Online
                C Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 8 Jul 2023, 12:57 last edited by
                #8

                @Saad02 Are you serious with the last screenshot? I mean - <qt_installation_path> should be replaced with your ... qt installation path. Also the command line properly tells you that qt-cmake is not found so what do you expect??

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

                S 1 Reply Last reply 8 Jul 2023, 15:45
                1
                • C Christian Ehrlicher
                  8 Jul 2023, 12:57

                  @Saad02 Are you serious with the last screenshot? I mean - <qt_installation_path> should be replaced with your ... qt installation path. Also the command line properly tells you that qt-cmake is not found so what do you expect??

                  S Offline
                  S Offline
                  Saad02
                  wrote on 8 Jul 2023, 15:45 last edited by
                  #9

                  @Christian-Ehrlicher Sir, it finds qt-make properly. And I have never made any driver or binary on by own. Then should I remove <qt_installation_path> and retry?
                  27f08dbd-f030-4d92-8355-9f5d44af8750-image.png

                  S 1 Reply Last reply 8 Jul 2023, 16:06
                  0
                  • S Saad02
                    8 Jul 2023, 15:45

                    @Christian-Ehrlicher Sir, it finds qt-make properly. And I have never made any driver or binary on by own. Then should I remove <qt_installation_path> and retry?
                    27f08dbd-f030-4d92-8355-9f5d44af8750-image.png

                    S Offline
                    S Offline
                    Saad02
                    wrote on 8 Jul 2023, 16:06 last edited by
                    #10

                    @Saad02 Ok, I understood little.
                    Code:
                    qt-cmake -G Ninja C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=C:/Qt/<platform> -DMySQL_INCLUDE_DIR="C:/mysql-8.0.33-winx64/include" -DMySQL_LIBRARY="C:/mysql-8.0.33-winx64/lib/mysqlclient.<so|dylib>"

                    Do I need to change anything here now?

                    T S 2 Replies Last reply 8 Jul 2023, 17:16
                    0
                    • S Saad02
                      8 Jul 2023, 16:06

                      @Saad02 Ok, I understood little.
                      Code:
                      qt-cmake -G Ninja C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=C:/Qt/<platform> -DMySQL_INCLUDE_DIR="C:/mysql-8.0.33-winx64/include" -DMySQL_LIBRARY="C:/mysql-8.0.33-winx64/lib/mysqlclient.<so|dylib>"

                      Do I need to change anything here now?

                      T Offline
                      T Offline
                      thecodemonkey
                      wrote on 8 Jul 2023, 17:16 last edited by
                      #11

                      @Saad02 try the following batch script (adjust the paths if necessary first):

                      set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
                      cd C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers
                      call C:\Qt\6.5.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.5.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
                      mingw32-make
                      mingw32-make install
                      pause
                      
                      S 2 Replies Last reply 8 Jul 2023, 18:02
                      0
                      • T thecodemonkey
                        8 Jul 2023, 17:16

                        @Saad02 try the following batch script (adjust the paths if necessary first):

                        set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
                        cd C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers
                        call C:\Qt\6.5.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.5.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
                        mingw32-make
                        mingw32-make install
                        pause
                        
                        S Offline
                        S Offline
                        Saad02
                        wrote on 8 Jul 2023, 18:02 last edited by
                        #12

                        @thecodemonkey I got some error when I used the command mingw32-make.
                        ![519252e7-a5af-4757-a934-d49f3834d0c0-image.png](Request Entity Too Large)

                        1 Reply Last reply
                        0
                        • T thecodemonkey
                          8 Jul 2023, 17:16

                          @Saad02 try the following batch script (adjust the paths if necessary first):

                          set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
                          cd C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers
                          call C:\Qt\6.5.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.5.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
                          mingw32-make
                          mingw32-make install
                          pause
                          
                          S Offline
                          S Offline
                          Saad02
                          wrote on 8 Jul 2023, 18:33 last edited by
                          #13

                          @thecodemonkey Sorry, the image is too large. I think I should just copy paste it.

                          Error:
                          C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers>mingw32-make
                          [ 4%] Built target QMYSQLDriverPlugin_version_script
                          [ 8%] Automatic MOC for target QMYSQLDriverPlugin
                          [ 8%] Built target QMYSQLDriverPlugin_autogen
                          [ 32%] Built target QMYSQLDriverPlugin
                          [ 36%] Built target QODBCDriverPlugin_version_script
                          [ 40%] Automatic MOC for target QODBCDriverPlugin

                          AutoMoc subprocess error

                          The moc process failed to compile
                          "SRC:/odbc/qsql_odbc_p.h"
                          into
                          "SRC:/odbc/QODBCDriverPlugin_autogen/include/moc_qsql_odbc_p.cpp"
                          included by
                          "SRC:/odbc/qsql_odbc.cpp"

                          Command

                          C:/Qt/6.5.1/mingw_64/./bin/moc.exe -DMINGW_HAS_SECURE_API=1 -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/include -IC:/MinGW/include -IC:/Qt/6.5.1/mingw_64/include/QtCore -IC:/Qt/6.5.1/mingw_64/include -IC:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -IC:/Qt/6.5.1/mingw_64/include/QtSql -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -IC:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include --include C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/moc_predefs.h --output-dep-file -o C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include/moc_qsql_odbc_p.cpp C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc_p.h

                          Output

                          :/Qt/6.5.1/mingw_64/include/QtCore/qnamespace.:24:1: error: Parse error at "attribute"

                          AutoMoc subprocess error

                          The moc process failed to compile
                          "SRC:/odbc/main.cpp"
                          into
                          "SRC:/odbc/QODBCDriverPlugin_autogen/include/main.moc"
                          included by
                          "SRC:/odbc/main.cpp"

                          Command

                          C:/Qt/6.5.1/mingw_64/./bin/moc.exe -DMINGW_HAS_SECURE_API=1 -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/include -IC:/MinGW/include -IC:/Qt/6.5.1/mingw_64/include/QtCore -IC:/Qt/6.5.1/mingw_64/include -IC:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -IC:/Qt/6.5.1/mingw_64/include/QtSql -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -IC:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include --include C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/moc_predefs.h --output-dep-file -o C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include/main.moc C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/main.cpp

                          Output

                          :/Qt/6.5.1/mingw_64/include/QtCore/qnamespace.:24:1: error: Parse error at "attribute"

                          mingw32-make[2]: *** [odbc\CMakeFiles\QODBCDriverPlugin_autogen.dir\build.make:70: odbc/CMakeFiles/QODBCDriverPlugin_autogen] Error 1
                          mingw32-make[1]: *** [CMakeFiles\Makefile2:355: odbc/CMakeFiles/QODBCDriverPlugin_autogen.dir/all] Error 2
                          mingw32-make: *** [Makefile:145: all] Error 2

                          T 1 Reply Last reply 8 Jul 2023, 19:34
                          0
                          • S Saad02
                            8 Jul 2023, 18:33

                            @thecodemonkey Sorry, the image is too large. I think I should just copy paste it.

                            Error:
                            C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers>mingw32-make
                            [ 4%] Built target QMYSQLDriverPlugin_version_script
                            [ 8%] Automatic MOC for target QMYSQLDriverPlugin
                            [ 8%] Built target QMYSQLDriverPlugin_autogen
                            [ 32%] Built target QMYSQLDriverPlugin
                            [ 36%] Built target QODBCDriverPlugin_version_script
                            [ 40%] Automatic MOC for target QODBCDriverPlugin

                            AutoMoc subprocess error

                            The moc process failed to compile
                            "SRC:/odbc/qsql_odbc_p.h"
                            into
                            "SRC:/odbc/QODBCDriverPlugin_autogen/include/moc_qsql_odbc_p.cpp"
                            included by
                            "SRC:/odbc/qsql_odbc.cpp"

                            Command

                            C:/Qt/6.5.1/mingw_64/./bin/moc.exe -DMINGW_HAS_SECURE_API=1 -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/include -IC:/MinGW/include -IC:/Qt/6.5.1/mingw_64/include/QtCore -IC:/Qt/6.5.1/mingw_64/include -IC:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -IC:/Qt/6.5.1/mingw_64/include/QtSql -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -IC:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include --include C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/moc_predefs.h --output-dep-file -o C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include/moc_qsql_odbc_p.cpp C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc_p.h

                            Output

                            :/Qt/6.5.1/mingw_64/include/QtCore/qnamespace.:24:1: error: Parse error at "attribute"

                            AutoMoc subprocess error

                            The moc process failed to compile
                            "SRC:/odbc/main.cpp"
                            into
                            "SRC:/odbc/QODBCDriverPlugin_autogen/include/main.moc"
                            included by
                            "SRC:/odbc/main.cpp"

                            Command

                            C:/Qt/6.5.1/mingw_64/./bin/moc.exe -DMINGW_HAS_SECURE_API=1 -DQODBCDriverPlugin_EXPORTS -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_UP_TO=0x040800 -DQT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN -DQT_SQL_LIB -DQT_WARN_DEPRECATED_UP_TO=0x070000 -DUNICODE -DWIN32 -DWIN64 -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_WIN64 -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc -IC:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/include -IC:/MinGW/include -IC:/Qt/6.5.1/mingw_64/include/QtCore -IC:/Qt/6.5.1/mingw_64/include -IC:/Qt/6.5.1/mingw_64/mkspecs/win32-g++ -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtCore/6.5.1/QtCore -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1 -IC:/Qt/6.5.1/mingw_64/include/QtSql/6.5.1/QtSql -IC:/Qt/6.5.1/mingw_64/include/QtSql -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++ -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/x86_64-w64-mingw32 -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include/c++/backward -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include -IC:/Qt/Tools/mingw1120_64/lib/gcc/x86_64-w64-mingw32/11.2.0/include-fixed -IC:/Qt/Tools/mingw1120_64/x86_64-w64-mingw32/include --include C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/moc_predefs.h --output-dep-file -o C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/QODBCDriverPlugin_autogen/include/main.moc C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers/odbc/main.cpp

                            Output

                            :/Qt/6.5.1/mingw_64/include/QtCore/qnamespace.:24:1: error: Parse error at "attribute"

                            mingw32-make[2]: *** [odbc\CMakeFiles\QODBCDriverPlugin_autogen.dir\build.make:70: odbc/CMakeFiles/QODBCDriverPlugin_autogen] Error 1
                            mingw32-make[1]: *** [CMakeFiles\Makefile2:355: odbc/CMakeFiles/QODBCDriverPlugin_autogen.dir/all] Error 2
                            mingw32-make: *** [Makefile:145: all] Error 2

                            T Offline
                            T Offline
                            thecodemonkey
                            wrote on 8 Jul 2023, 19:34 last edited by
                            #14

                            @Saad02 I know, building SQL drivers can be a pain in the A-S-S. That's the reason I provide pre-built QMYSQL drivers on my github page, to spare others that pain

                            Does anything change if you run configure.bat first?

                            set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
                            cd C:\Qt\6.5.1\Src
                            configure.bat -sql-mysql -- -DCMAKE_INCLUDE_PATH="C:\mysql-8.0.33-winx64\include" -DCMAKE_LIBRARY_PATH="C:\mysql-8.0.33-winx64\lib"
                            cd C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers
                            call C:\Qt\6.5.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.5.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
                            mingw32-make
                            mingw32-make install
                            pause
                            
                            S 1 Reply Last reply 9 Jul 2023, 05:18
                            0
                            • S Saad02
                              8 Jul 2023, 16:06

                              @Saad02 Ok, I understood little.
                              Code:
                              qt-cmake -G Ninja C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=C:/Qt/<platform> -DMySQL_INCLUDE_DIR="C:/mysql-8.0.33-winx64/include" -DMySQL_LIBRARY="C:/mysql-8.0.33-winx64/lib/mysqlclient.<so|dylib>"

                              Do I need to change anything here now?

                              S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 8 Jul 2023, 20:26 last edited by
                              #15

                              @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                              @Saad02 Ok, I understood little.
                              Code:
                              qt-cmake -G Ninja C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=C:/Qt/<platform> -DMySQL_INCLUDE_DIR="C:/mysql-8.0.33-winx64/include" -DMySQL_LIBRARY="C:/mysql-8.0.33-winx64/lib/mysqlclient.<so|dylib>"

                              Do I need to change anything here now?

                              As already said several times: all the values between a < and > must be replaced by suitable values.

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

                              S 1 Reply Last reply 9 Jul 2023, 05:29
                              0
                              • T thecodemonkey
                                8 Jul 2023, 19:34

                                @Saad02 I know, building SQL drivers can be a pain in the A-S-S. That's the reason I provide pre-built QMYSQL drivers on my github page, to spare others that pain

                                Does anything change if you run configure.bat first?

                                set PATH=%PATH%;C:\Qt\Tools\mingw1120_64\bin;C:\Qt\Tools\CMake_64\bin
                                cd C:\Qt\6.5.1\Src
                                configure.bat -sql-mysql -- -DCMAKE_INCLUDE_PATH="C:\mysql-8.0.33-winx64\include" -DCMAKE_LIBRARY_PATH="C:\mysql-8.0.33-winx64\lib"
                                cd C:\Qt\6.5.1\Src\qtbase\src\plugins\sqldrivers
                                call C:\Qt\6.5.1\mingw_64\bin\qt-cmake.bat -G "MinGW Makefiles" . -DMySQL_INCLUDE_DIR="C:\mysql-8.0.33-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.33-winx64\lib\libmysql.lib" -DCMAKE_INSTALL_PREFIX="C:\Qt\6.5.1\mingw_64" -DCMAKE_C_COMPILER="gcc.exe" -DCMAKE_CXX_COMPILER="g++.exe"
                                mingw32-make
                                mingw32-make install
                                pause
                                
                                S Offline
                                S Offline
                                Saad02
                                wrote on 9 Jul 2023, 05:18 last edited by
                                #16

                                @thecodemonkey Sir, I extracted those in my project file is it, ok? (But it didn't work)
                                And did you mean any of the folder in Qt by "subdirectory "?

                                Also, this code also got me the same error.

                                T 1 Reply Last reply 9 Jul 2023, 06:16
                                0
                                • S SGaist
                                  8 Jul 2023, 20:26

                                  @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                                  @Saad02 Ok, I understood little.
                                  Code:
                                  qt-cmake -G Ninja C:/Qt/6.5.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=C:/Qt/<platform> -DMySQL_INCLUDE_DIR="C:/mysql-8.0.33-winx64/include" -DMySQL_LIBRARY="C:/mysql-8.0.33-winx64/lib/mysqlclient.<so|dylib>"

                                  Do I need to change anything here now?

                                  As already said several times: all the values between a < and > must be replaced by suitable values.

                                  S Offline
                                  S Offline
                                  Saad02
                                  wrote on 9 Jul 2023, 05:29 last edited by
                                  #17

                                  @SGaist Then what should I replace the <platform> and <soIdylib> with? If I am not wrong the 2nd one is ".lib".
                                  Also, is it possible for you to gimme the exact code that I can run directly? It seems to be a little tough for me though I tried.

                                  1 Reply Last reply
                                  0
                                  • S Saad02
                                    9 Jul 2023, 05:18

                                    @thecodemonkey Sir, I extracted those in my project file is it, ok? (But it didn't work)
                                    And did you mean any of the folder in Qt by "subdirectory "?

                                    Also, this code also got me the same error.

                                    T Offline
                                    T Offline
                                    thecodemonkey
                                    wrote on 9 Jul 2023, 06:16 last edited by
                                    #18

                                    @Saad02 there are two possibilites, both should work:

                                    1. in Qt installation dir. For MinGW that would be something like C:\Qt\6.5.1\mingw_64\plugins\sqldrivers
                                    2. a subdirectory in your project build path (where the compiler creates the exe file of your project), like this:
                                      384f1057-3474-418b-a20d-567e326c208a-grafik.png

                                    libmysql.dll must be accessible, too. So either copy it to your project build path, or some other path that is added to your PATH environment variable

                                    S 1 Reply Last reply 9 Jul 2023, 07:53
                                    0
                                    • T thecodemonkey
                                      9 Jul 2023, 06:16

                                      @Saad02 there are two possibilites, both should work:

                                      1. in Qt installation dir. For MinGW that would be something like C:\Qt\6.5.1\mingw_64\plugins\sqldrivers
                                      2. a subdirectory in your project build path (where the compiler creates the exe file of your project), like this:
                                        384f1057-3474-418b-a20d-567e326c208a-grafik.png

                                      libmysql.dll must be accessible, too. So either copy it to your project build path, or some other path that is added to your PATH environment variable

                                      S Offline
                                      S Offline
                                      Saad02
                                      wrote on 9 Jul 2023, 07:53 last edited by
                                      #19

                                      @thecodemonkey Sir, copied all files in release and debug, qmysql.lib in C:\Qt\6.5.1\mingw_64\plugins\sqldrivers and also added the folder in environment. But it didn't work.

                                      T 1 Reply Last reply 9 Jul 2023, 08:02
                                      0
                                      • S Saad02
                                        9 Jul 2023, 07:53

                                        @thecodemonkey Sir, copied all files in release and debug, qmysql.lib in C:\Qt\6.5.1\mingw_64\plugins\sqldrivers and also added the folder in environment. But it didn't work.

                                        T Offline
                                        T Offline
                                        thecodemonkey
                                        wrote on 9 Jul 2023, 08:02 last edited by
                                        #20

                                        @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                                        But it didn't work.

                                        Please be more specific

                                        S 1 Reply Last reply 9 Jul 2023, 08:18
                                        0
                                        • T thecodemonkey
                                          9 Jul 2023, 08:02

                                          @Saad02 said in How to create Qt 6.5 mysql driver with cmake?:

                                          But it didn't work.

                                          Please be more specific

                                          S Offline
                                          S Offline
                                          Saad02
                                          wrote on 9 Jul 2023, 08:18 last edited by
                                          #21

                                          @thecodemonkey
                                          62be54c3-1dbd-4f20-8628-555ec7859c58-image.png
                                          36e33d9e-e8ee-49ed-9a81-9acb94cc1206-image.png
                                          e8916716-4c06-4cd6-a85e-8a7484042861-image.png
                                          9a22a9b9-8fc8-456b-b124-b157f97ee167-image.png

                                          Also, added "qsqlmysql.dll_Qt_SQL_driver_6.5.1_MinGW_11.2.0_64-bit" folder in environment variables' system variables' path.
                                          I have nothing to hide :)

                                          T 1 Reply Last reply 9 Jul 2023, 10:37
                                          0

                                          11/60

                                          8 Jul 2023, 17:16

                                          topic:navigator.unread, 49
                                          • Login

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