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. QMYSQL driver not loaded. Windows x64 deployment.
Forum Updated to NodeBB v4.3 + New Features

QMYSQL driver not loaded. Windows x64 deployment.

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.2k 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.
  • J Offline
    J Offline
    Jari Koivuluoma
    wrote on last edited by Jari Koivuluoma
    #1

    I know there are many topics concerning this stuff but I am new to Qt and to PC software development in general, and I cant seem to get this to work. I'm probably lacking a basic grasp of some things.

    I have written this small console app to write stuff to MySQL database.
    In order to get it to work even on my development PC, I had to compile the database drivers as discussed a lot in topics concerning this matter.

    After that, I used windeployqt to get the dependencies and it gathered them nicely. However, when I copied my app to another 64 bit Windows, the app tells me that

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    

    It works on my development machine, so I tried renaming libmysql.dll on my Windows folder to something else to determine if that is the dll the app is using, and it turned out that it was.

    Then I copied that to my target machines Windows folder AND to the folder of my executable at the target machine. This did not do the trick. Why is that? Since both machines are x64 Windows 10 and I have compiled the app using msvc2015_64 in release mode.

    It was not totally clear to me that what I was doing when I was compiling the drivers. If I understood correctly the end result of that was the qsqlmysql.dll file in the sqldrivers folder. So using the lib, dll and the h files in the MySQL server install directory I compiled this driver.

    Edit: This is what I did exactly
    Opened Qt MSVC2015_64 console
    ran C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat
    ran qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Server 8.0\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Server 8.0\lib"
    ran nmake
    ran nmake install

    Of course the entire sqldrivers folder was copied to the target along with the app and yet it does not work so what gives? Do I somehow have to repeat this process on the target machine?

    To clarify, the database is running on the target machine, but its also installed on the development machine and I used the development machine files in the driver compilation.

    Development OS: Windows 10 Home x64
    Target OS: Windows 10 Enterprice LTSC x64
    Qt version: 5.15.2 MSVC2015 x64
    Qt Creator: 4.14.1
    MySQL server: 8.0.23 x64

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

      Hi,

      Did you forget to deploy the MySQL .dlls and their dependencies along your application ?

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

      J 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you forget to deploy the MySQL .dlls and their dependencies along your application ?

        J Offline
        J Offline
        Jari Koivuluoma
        wrote on last edited by Jari Koivuluoma
        #3

        @SGaist Meaning all the files in my C:\Program Files\MySQL\MySQL Server 8.0\lib directory? Not just libmysql.dll? Or how do I know all the dependencies? I have tried the dependency walker on my exe and I don't quite understand it. It gives me loads of errors on some file that look like that they have something to do with windows, but no files that seem to me be related to mysql. Still the app starts. I should probably take a closer look at the dependency walker.

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

          No, not all files.

          You can use a tool like Dependency Walker or Dependencies to see what is required.

          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
          • J Offline
            J Offline
            Jari Koivuluoma
            wrote on last edited by Jari Koivuluoma
            #5

            I tried the dependency walker and first of all, there are probably around 300 of these API-MS-WIN-CORE****.DLL:s which it says that "Error opening file. The system cannot find the file specified (2)."
            Same thing with files starting with EXT-MS-WIN....

            In addition there are loads of files having the wrong architecture (x86).

            At the top level there is the only thing that I can tell that is related to MySQL is QT5SQL.dll but seems to be OK judging by the icon.

            When I expand it, there is KERNEL32.dll giving me that same warning about the architecture but nothing about MySQL. Under the QT5SQL, there is the same warning about NTDLL.DLL, VCRUNTIME140.DLL, UCRTBASE.DLL

            I compared the results when running the dep walker on the development PC an on the target PC and they are pretty much the same from what I can tell.

            There is just nothing that seems to clearly have something to do with MySQL and so much other stuff. Seems kind of impossible to figure it out from this.

            Maybe Ill post some pictures tomorrow.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Show full paths and only look for dlls from the mysql directory

              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
              0
              • nageshN Offline
                nageshN Offline
                nagesh
                wrote on last edited by
                #7

                @Jari-Koivuluoma said in QMYSQL driver not loaded. Windows x64 deployment.:

                QMYSQL driver not loaded

                copy "libmysql.dll" to the deployment directory where your application exists.

                1 Reply Last reply
                1
                • H Offline
                  H Offline
                  haris123
                  wrote on last edited by haris123
                  #8

                  In my case Windows 10 while deploying to other PC, I have to copy, libmysql.dll, libcrypto-1_1-x64.dll and libssl-1_1-x64.dll and sqldriver folder(which will added by windwployqt.exe) to app folder.

                  It can download from here https://github.com/thecodemonkey86/qt_mysql_driver/releases/tag/qmysql_6.4.1 , or copy from mysql install directory.

                  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