[SOLVED] sql driver plugins not loadded



  • Hi everybody.

    I got following lines and program can not connect mysql database.


    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers:

    I entered the command "ldd libqsqlmysql.so"


    linux-vdso.so.1 (0x00007fff9b5fc000)
    libmysqlclient.so.18 => /usr/lib64/libmysqlclient.so.18 (0x00007f2c436c1000)
    libQt5Sql.so.5 => /home/ckurdu/bin/Qt5.4.1/5.4/gcc_64/lib/libQt5Sql.so.5 (0x00007f2c43480000)
    libQt5Core.so.5 => /home/ckurdu/bin/Qt5.4.1/5.4/gcc_64/lib/libQt5Core.so.5 (0x00007f2c42d44000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2c42b27000)
    libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f2c4281e000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f2c4251d000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f2c42306000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f2c41f5e000)
    libz.so.1 => /lib64/libz.so.1 (0x00007f2c41d48000)
    libssl.so.1.0.0 => /lib64/libssl.so.1.0.0 (0x00007f2c41ae1000)
    libcrypto.so.1.0.0 => /lib64/libcrypto.so.1.0.0 (0x00007f2c416bd000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f2c414b9000)
    libicui18n.so.53 => /home/ckurdu/bin/Qt5.4.1/5.4/gcc_64/lib/libicui18n.so.53 (0x00007f2c4106d000)
    libicuuc.so.53 => /home/ckurdu/bin/Qt5.4.1/5.4/gcc_64/lib/libicuuc.so.53 (0x00007f2c40ce1000)
    libgthread-2.0.so.0 => /usr/lib64/libgthread-2.0.so.0 (0x00007f2c40adf000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f2c408d7000)
    libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007f2c405c8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2c43e78000)
    libicudata.so.53 => /home/ckurdu/bin/Qt5.4.1/5.4/gcc_64/lib/libicudata.so.53 (0x00007f2c3ef40000)
    libpcre.so.1 => /usr/lib64/libpcre.so.1 (0x00007f2c3ecd5000)

    So there is no unfounded library file.


  • Lifetime Qt Champion

    Hi,

    Did you check the error message returned by QSqlDatabase ?




  • this->dbo->setHostName(hostname);
    this->dbo->setDatabaseName(databasename);
    this->dbo->setUserName(username);
    this->dbo->setPassword(password);
    if (!this->dbo->open()) {
    qDebug()<<"Database Error"<<this->dbo->lastError().text()<<endl;
    return false;
    }

    I got "Driver not loaded Driver not loaded" error.
    Why is it twice?


  • Lifetime Qt Champion

    Looks like you are doing something unusual.

    QSqlDatabase's initialization should rather look like:

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL")
    db.setHostname(hostname);
    etc.
    

    How are you doing it ?

    Another thing that is puzzling is that your plugin list is empty.
    What does
    qDebug() << QSqlDatabase::drivers();
    return ?



  • This is the full code of creation of database connection.


    bool Factory::createConnection()
    {
    qDebug()<<"Connection has been creating"<<endl;
    this->dbo = new QSqlDatabase(QSqlDatabase::addDatabase("QMYSQL"));
    this->setting->beginGroup("database");
    QString hostname = this->setting->value("host").toString();
    QString username = this->setting->value("user").toString();
    QString password = this->setting->value("password").toString();
    QString databasename = this->setting->value("databasename").toString();

        qDebug()<<"password : "<<password<<endl;
        this->dbo->setHostName(hostname);
        this->dbo->setDatabaseName(databasename);
        this->dbo->setUserName(username);
        this->dbo->setPassword(password);
        if (!this->dbo->open()) {
           qDebug() <<"Available Drivers : " << QSqlDatabase::drivers()<<endl;
            qDebug()<<"Database Error : "<<this->dbo->lastError().text()<<endl;
            return false;
        }
        qDebug()<<"Database connected"<<endl;
        return true;
    

    }


    Output of this program.

    Plugins location "/home/ckurdu/bin/Qt_5_4.1/5.4/gcc_64/plugins"

    Plugins Prefixpath "/home/ckurdu/bin/Qt_5_4.1/5.4/gcc_64"

    Factory loaded

    Connection has been creating

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers:
    password : "wqerqwefas"

    **Available Drivers : () **
    **Database Error : "Driver not loaded Driver not loaded" **

    Module not loaded

    "The shared library was not found."

    Module not loaded

    "The shared library was not found."


  • Lifetime Qt Champion

    Did you build Qt yourself ?



  • No
    I only built myself libqsqlmysql.so. Also I installed qt 5.4.1 3 hours ago.
    My os is Opensuse 13.2 64 bit.


  • Lifetime Qt Champion

    Might sound silly, but did you also installed it ? I'm still puzzled by that empty list of drivers...



  • I am so sorry. I found the problem. I made a stupid error. in my qt.conf file I wrote wrong path for prefix. So program couldn't have found the plugin location.

    Thank you very much.


  • Lifetime Qt Champion

    Are you doing a deployment ?



  • Actually I have a main program that has already deployed for my desktop computer and I am programming a module for it. I copied the program from my desktop to my laptop than I continued to develop my module where I left off. But I forget to change "my.conf" file for the main program.

    Thank you.


  • Lifetime Qt Champion

    Wouldn't it be simpler also for debugging to build both ?

    In any case, since you have it working now, please mark the thread as solved so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.