Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to change searching path to MariaDB's C Connector "plugin" folder?



  • Hello everyone! (sorry for my (probably) bad English)
    I have an isssue after compilation of qmysql driver (Qt 5.14.2; MinGW 7.3.0, 32-bit; Qt Creator 4.11.2; MariaDB C Connector 3.1.7, Win32). The compilation was succesfully and I've got 3 files: qsqlmysql.dll, qsqlmysql.dll.debug and libqsqlmysql.a. I placed those files into compiler's plugins (sqldrivers) and created a project to test it. After building and launching the following code

    #include <QCoreApplication>
    #include <QDebug>
    #include <QtSql>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        QSqlDatabase db(QSqlDatabase::addDatabase("QMYSQL"));
    
        db.setUserName("root");
        db.setPassword("somepassword");
        db.setDatabaseName("mydb");
    
        db.open() ?  qDebug() << db.tables(): qDebug() << db.lastError();
    
        return a.exec();
    }
    
    

    I got the following debug: "QSqlError("1045", "QMYSQ: Unable to connect", "Plugin caching_sha2_password could not be loaded: Specified module not found. Library path is 'C:/Program Files (x86)/mariadb-connector-c/lib/mariadb/plugin/caching_sha2_password.dll'")

    Yes, there are no "mariadb-connector-c" folder in "C:/Program Files (x86)" directory. I created requested directory and placed there "plugin" folder with all MariaBD's connector plugins. After this all works correctly. But is there are a way to change the searching directory?

    The ways I tried to solve this problem is below. Probably some of those ways looks discouragingly but I tried all ways which I've been ever able to use:

    1. Added LIBS += "path-to-mariadb/plugin/caching_sha2_password.dll". Nothing has changed, the same error;
    2. Placed the MariaDB's "plugin" folder near the builded .exe file. Nothing has changed, the same error;
    3. Created QT_PLUGIN_PATH environment variable and placed the path to the MariaBD's plugin folder. Nothing has changed, the same error;
    4. Used QCoreApplication::addLibraryPath() and QCoreApplication::setLibraryPaths() functions right after creating an QCoreApplication object. No effect, the same error;
    5. Added QMAKE_LIBDIR += "path-to-mariadb/plugin". No effect, the same error;
    6. Copied "qt.conf" file from mingw73_32's "bin" folder into the folder with builded .exe file. Added Plugins=path_to_plugin_folder. After fail, tried to replace "Plugins" to "Libraries". And failed again :) The same error.
    7. Tried to use QLibrary class. The same error.

  • Lifetime Qt Champion

    @Zerkg said in How to change searching path to MariaDB's C Connector "plugin" folder?:

    caching_sha2_password.dll'

    So where is this shared lib? It must be in the same dir as qsqlmysql.dll otherwise the library can not be loaded.



  • @Christian-Ehrlicher Hello!
    The shared lib's path is C:\Qt\MySQL\lib\plugin.
    If I understood you correctly, I must copy caching_sha2_password.dll into compiler's sqldrivers folder, right? I Just tried to copy it but I still have the same error.
    The library caching_sha2_password.dll is loading correctly if place it to debug's specified path (C:/Program Files (x86)/mariadb-connector-c/lib/mariadb/plugin/caching_sha2_password.dll'). I can't understand why Qt looking for this library using specified path and how to change it.


  • Moderators

    If I were to guess you have that directory in your PATH variable, you could check that to make sure.



  • @kshegunov Hi there and thanks for trying to help me!
    I checked my PATH variable. There are no "C:/Program Files (x86)/mariadb-connector-c/..." directories. I also tried to add paths to MySQL, lib and plugin foldes. My current PATH variable looks like
    84d79229-56e1-416c-a6f7-0d11506f55ca-image.png
    but I still get the same error.

    I forgot to add in my topic that in Qt's SQL Database Drivers there are the following text:

    The configure script cannot detect the necessary libraries and include files if they are not in the standard paths, so it may be necessary to specify these paths using the *_INCDIR=, *_LIBDIR=, or *_PREFIX= command-line options. For example, if your MySQL files are installed in /usr/local/mysql (or in C:/Program Files/MySQL/MySQL Connector C 6.1 on Windows), then pass the following parameter to configure: MYSQL_PREFIX=/usr/local/mysql (or MYSQL_PREFIX="C:/Program Files/MySQL/MySQL Connector C 6.1" for Windows).

    I tried to use it and this is what I got:
    cdfd547b-d5df-4230-9077-2e8869fe3062-image.png

    But still, nothing has changed. Maybe I did something wrong? Or using configure utility is only revelant when you build the driver?


  • Lifetime Qt Champion

    @Zerkg Please follow the documentation - there is nowhere a statement that you should run configure...



  • @Christian-Ehrlicher said in How to change searching path to MariaDB's C Connector "plugin" folder?:

    Please follow the documentation - there is nowhere a statement that you should run configure...

    I understand but I'm new in Qt and I don't have enough knowledge and experience so I checking every way that can potentially help me to solve the problem... Inconclusively :)
    Probably I made a mistake during qmysql driver's compilation because I used this way to do it (but I used MariaDB C Connector instead of MySQL C Connector). The documentation describe another way but when I tried to follow it I got a "No rule for target sub-mysql. Stop.". Now I trying to build qmysql driver using MySQL C Connector 6.1.11... This is the last of my ideas how to fix this problem.


Log in to reply