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 compile QMYSQL plugin with MSVC?
Forum Updated to NodeBB v4.3 + New Features

How to compile QMYSQL plugin with MSVC?

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 3 Posters 617 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.
  • C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 26 Mar 2025, 19:40 last edited by
    #9

    You did not open the correct visual studio command prompt so the vc env variables are not properly set up.

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

    1 Reply Last reply
    2
    • B Offline
      B Offline
      BushyAxis793
      wrote on 27 Mar 2025, 18:10 last edited by
      #10

      OK. So I used Visual Studio Developer Command Prompt and got different errors. I tried also PowerShell but no result. Should I install any special version for MSVC?

      C 1 Reply Last reply 27 Mar 2025, 19:53
      0
      • B BushyAxis793
        27 Mar 2025, 18:10

        OK. So I used Visual Studio Developer Command Prompt and got different errors. I tried also PowerShell but no result. Should I install any special version for MSVC?

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 27 Mar 2025, 19:53 last edited by
        #11

        @BushyAxis793 said in How to compile QMYSQL plugin with MSVC?:

        Should I install any special version for MSVC?

        Why?
        Start with a clean build dir from a properly set up environment and if you encounter errors, post them here.

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

        1 Reply Last reply
        1
        • B Offline
          B Offline
          BushyAxis793
          wrote on 28 Mar 2025, 17:41 last edited by BushyAxis793
          #12

          OK. I understand. Let me show you step by step what I do:

          1. Clear everything
          2. Open Visual Studio Developer Command Prompt
          3. I go to C:\mysql-8.0.28-winx64\

          9cb7c942-bd58-4375-badc-3869248544e0-image.png

          1. I create build-sqldrivers directory

          edb02edb-6fce-4392-8ac3-b9fc15116a7f-image.png

          1. I go to build-sqldrivers directory

          37c92a06-4c75-4a96-9368-6c44e4c8e545-image.png

          1. I input command:
            qt-cmake -G Ninja C:\Qt\6.3.0\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=C:\Qt\Tools\CMake_64\bin -DMySQL_ROOT="C:\mysql-8.0.28-winx64\mysql-8.0.28-winx64"

          And I got error

          https://justpaste.it/f66k3

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 28 Mar 2025, 18:11 last edited by
            #13

            Hostx86/x86/

            You opened the wrong visual studio command prompt. Qt is built with 64bits...

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

            1 Reply Last reply
            1
            • B Offline
              B Offline
              BushyAxis793
              wrote on 28 Mar 2025, 18:50 last edited by
              #14

              OK. So I run again Visual Studio Command Prompt and check configuration with:

              C:\Users\mnawr\source\repos\Project2>echo %VSCMD_ARG_TGT_ARCH%
              x86
              

              Then I change to x64 with:

              set VSCMD_ARG_TGT_ARCH=x64
              

              And check again:

              C:\Users\mnawr\source\repos\Project2>echo %VSCMD_ARG_TGT_ARCH%
              x64
              

              And again create build-sqldrivers directory, run qt-cmake.. and got the error again:

              https://justpaste.it/fvn4x

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 28 Mar 2025, 18:52 last edited by
                #15

                Please open the correct visual studio command prompt for 64 bits... is it really that hard?

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

                1 Reply Last reply
                1
                • B Offline
                  B Offline
                  BushyAxis793
                  wrote on 28 Mar 2025, 19:35 last edited by
                  #16

                  OK. I used x64 Native Tools Command Prompt for VS 2022 and my result is:

                  **********************************************************************
                  ** Visual Studio 2022 Developer Command Prompt v17.13.5
                  ** Copyright (c) 2022 Microsoft Corporation
                  **********************************************************************
                  [vcvarsall.bat] Environment initialized for: 'x64'
                  
                  C:\Program Files\Microsoft Visual Studio\2022\Community>cd C:\mysql-8.0.28-winx64
                  
                  C:\mysql-8.0.28-winx64>mkdir build-sqldrivers
                  
                  C:\mysql-8.0.28-winx64>cd build-sqldrivers
                  
                  C:\mysql-8.0.28-winx64\build-sqldrivers>qt-cmake -G Ninja C:\Qt\6.3.0\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=C:\Qt\Tools\CMake_64\bin -DMySQL_ROOT="C:\mysql-8.0.28-winx64\mysql-8.0.28-winx64"
                  -- The CXX compiler identification is MSVC 19.43.34809.0
                  -- The C compiler identification is MSVC 19.43.34809.0
                  -- The ASM compiler identification is MSVC
                  -- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
                  -- Detecting CXX compiler ABI info
                  -- Detecting CXX compiler ABI info - done
                  -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe - skipped
                  -- Detecting CXX compile features
                  -- Detecting CXX compile features - done
                  -- Detecting C compiler ABI info
                  -- Detecting C compiler ABI info - done
                  -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe - skipped
                  -- Detecting C compile features
                  -- Detecting C compile features - done
                  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
                  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
                  -- Looking for pthread_create in pthreads
                  -- Looking for pthread_create in pthreads - not found
                  -- Looking for pthread_create in pthread
                  -- Looking for pthread_create in pthread - not found
                  -- Found Threads: TRUE
                  -- Performing Test HAVE_STDATOMIC
                  -- Performing Test HAVE_STDATOMIC - Success
                  -- Found WrapAtomic: TRUE
                  
                  -- Configuring done (9.9s)
                  -- Generating done (0.6s)
                  -- Build files have been written to: C:/mysql-8.0.28-winx64/build-sqldrivers
                  
                  C:\mysql-8.0.28-winx64\build-sqldrivers>cmake --build .
                  [22/22] Linking CXX shared module plugins\sqldrivers\qsqlmysqld.dll
                  
                  C:\mysql-8.0.28-winx64\build-sqldrivers>cmake --install .
                  -- Install configuration: "Debug"
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfig.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersion.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginConfigVersionImpl.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlmysqld.dll
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginTargets-debug.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlmysqld.pdb
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QMYSQLDriverPluginAdditionalTargetInfo.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfig.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersion.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginConfigVersionImpl.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlodbcd.dll
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginTargets.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginTargets-debug.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlodbcd.pdb
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QODBCDriverPluginAdditionalTargetInfo.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfig.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersion.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginConfigVersionImpl.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlited.dll
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginTargets-debug.cmake
                  -- Installing: C:/Qt/Tools/CMake_64/bin/./plugins/sqldrivers/qsqlited.pdb
                  -- Installing: C:/Qt/Tools/CMake_64/bin/lib/cmake/Qt6Sql/Qt6QSQLiteDriverPluginAdditionalTargetInfo.cmake
                  
                  C:\mysql-8.0.28-winx64\build-sqldrivers>
                  

                  I can't see any error but when I go to C:\mysql-8.0.28-winx64\build-sqldrivers\plugins\sqldrivers

                  9e661484-dcd9-421c-af17-de6d47817899-image.png

                  I expected qsqlmysql.dll instead of qsqlmysqld.dll.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 28 Mar 2025, 19:57 last edited by
                    #17

                    You have to build debug and release libs (msvc is picky here)

                    -DCMAKE_BUILD_TYPE=Release

                    -DCMAKE_BUILD_TYPE=Debug

                    Debug was already built.

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

                    1 Reply Last reply
                    2
                    • B Offline
                      B Offline
                      BushyAxis793
                      wrote on 29 Mar 2025, 10:33 last edited by
                      #18

                      Thanks for reply. I run:
                      qt-cmake with -DCMAKE_BUILD_TYPE=Release parameter. Now my C:\mysql-8.0.28-winx64\build-sqldrivers\plugins\sqldrivers directory looks much better:

                      7658df53-1a08-4851-991c-417bbe8ba871-image.png

                      I can see qsqlmysql.dll.

                      I added to my project. It works perfect!

                      Thank you very much for help and for you patience!

                      Have a good day :]

                      1 Reply Last reply
                      1
                      • B BushyAxis793 has marked this topic as solved on 29 Mar 2025, 10:34

                      18/18

                      29 Mar 2025, 10:33

                      • Login

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