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. Problem with QMYSQL
Forum Update on Monday, May 27th 2025

Problem with QMYSQL

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmysqllibmysqlmysqllibrarymingw
8 Posts 2 Posters 1.1k 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.
  • A Offline
    A Offline
    AlexW.QT
    wrote on 24 Aug 2019, 13:34 last edited by AlexW.QT
    #1

    Hi. I know that there's a lot of topics about it, but this is uncommon.
    Problem is that qmysql.dll loads ONLY from mingw folder and nothing helps. fighting with this 2 days and cant resolve it.
    pls help

    here's some code (setting up libs load from exe folder):
    QStringList str;
    str.append(".");
    qApp->setLibraryPaths(str);

    in PRO:
    QTPLUGIN += QSQLMYSQL
    QT += sql core gui
    alt text

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Aug 2019, 15:06 last edited by
      #2

      Hi and welcome to devnet,

      If you want the plugin to load when deploying your application, you have to respect the folder hierarchy. So you have to keep plugins/sqldrivers beside 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

      1 Reply Last reply
      1
      • A Offline
        A Offline
        AlexW.QT
        wrote on 24 Aug 2019, 22:10 last edited by
        #3

        It is. All the folders near exe. All dlls in there.
        Used windeployqt for it. All ok if only mingw folder exists, if not - won't load and not workin'

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 Aug 2019, 22:45 last edited by
          #4

          Did you also deploy MinGW's dlls ?

          One thing you can do is start your application from the command line with the QT_DEBUG_PLUGINS environnement variable set to 1.

          You'll what is happening when your plugins are getting loaded.

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

          A 1 Reply Last reply 25 Aug 2019, 06:47
          0
          • S SGaist
            24 Aug 2019, 22:45

            Did you also deploy MinGW's dlls ?

            One thing you can do is start your application from the command line with the QT_DEBUG_PLUGINS environnement variable set to 1.

            You'll what is happening when your plugins are getting loaded.

            A Offline
            A Offline
            AlexW.QT
            wrote on 25 Aug 2019, 06:47 last edited by
            #5

            @sgaist all in there (every folder have from 1 up to 9 dlls)

            alt text

            And this is sqldrivers folder

            alt text

            Problem is that if C:\Qt\5.11.3\mingw53_32\plugins\qsqlmysql.dll exists, all ok. If I remove it - it doesn't loads from exe folder and C:\Deploy\libmysql.dll not loading too.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AlexW.QT
              wrote on 25 Aug 2019, 08:17 last edited by
              #6

              FOUND WHERE'S PROBLEM

              But still need help.

              Problem is that driver loading before setting up default folder:

              QStringList str;
              str.append("C:\Deploy");
              qApp->setLibraryPaths(str);

              And getting this err:

              QSqlDatabase: QMYSQL driver not loaded
              QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
              QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins
              my library path : ("C:\Deploy")

              Problem in database.cpp:

              #include "database.h"
              static QSqlDatabase datb = QSqlDatabase::addDatabase("QMYSQL", "datas");
              static QSqlQuery query(datb);

              static QString host = "site.host";
              static QString namedb = "name";
              static QString nameusr = "usr";
              static QString passdb = "pass";
              //db login & open
              void Database::login_db()
              {
              }

              Exact problem in:
              static QSqlDatabase datb = QSqlDatabase::addDatabase("QMYSQL", "datas");

              This line loading before int main(int argc, char *argv[]) and upload's qmysql from default folder of mingw

              If I remove it from there and put into login func all with loading is ok:
              alt text

              But doesn't work then my functions. How can I solve it? how to move these lines in another place:

              static QSqlDatabase datb= QSqlDatabase::addDatabase("QMYSQL", "datab");
              static QSqlQuery query(datb);

              I mean load 'em later than main.cpp

              1 Reply Last reply
              0
              • A Offline
                A Offline
                AlexW.QT
                wrote on 25 Aug 2019, 08:49 last edited by
                #7

                OR make default DIR outside of main OR in .PRO file.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 25 Aug 2019, 19:03 last edited by
                  #8

                  Are you trying to move things around in the folder where you are currently doing the application deployment ?

                  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

                  1/8

                  24 Aug 2019, 13:34

                  • Login

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