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

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 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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 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
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          0
          • SGaistS SGaist

            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 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 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 last edited by
                #7

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

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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

                  • Login

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