PDA

View Full Version : Help with QMYSQL driver for QT 4.4.0: driver not loaded



khikho
7th January 2009, 18:58
Dear,

I have done a fair share of googling and reading post in this forum. However I am still having a problem of the application complaining of "QMYSQL driver not loaded"

Here is what I have:

1) The OS is redhat enterprise kernel 2.6x
2) The OS come loaded with qt 3.6
3) I extract qt 4.4.0 and compiled in a seperate location let's call it $QTDIR, I have compile and run other QT application fine --> suggested that I have the 4.4.0 environment set up correctly.
4) the QTDIR has the following plugins:
$QTDIR/plugins/sqldrivers/libqsqlite.a
$QTDIR/plugins/sqldrivers/libqsqlmysql.a
5) I have QT += sql in the .pro file
6) The following code yield the following error:

int main( int argc, char **argv )
{
QCoreApplication app( argc, argv );
qDebug() << "Sql driver " << QSqlDatabase::drivers();
QSqlDatabase db( QSqlDatabase::addDatabase( "QMYSQL" ) );
qDebug() << db.lastError();
}


The result is :
Sql driver ()
QSqldatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlError(-1, "Driver not loaded", "Driver not loaded");


8) After extensive googling, it all seem to suggest a recompile of mysql plugin, the question is, if i already have the qsqlmysql.a in the plugins/sqldrivers/ do I still need to recompile it? What am I doing wrong?

Please help.

Thanks

khikho

KaptainKarl
8th January 2009, 11:10
If it was me, I'd download and install a newer version of QT.
If you read the configure help, it will show you how to make sure QT is configured with MySQL.

Karl

khikho
8th January 2009, 13:33
Thanks for replying,

For the future, I was compiling qt as static library with just the mysql plugin, this explain the present of qsqlmysql.a but not the share library.

A reconfiguring and recompiling of qt as share library and including mysql driver, not just as a plugin, solved the problem.

cheer
khikho

Srinivas_30sep
1st April 2011, 10:40
Thanks for replying,

For the future, I was compiling qt as static library with just the mysql plugin, this explain the present of qsqlmysql.a but not the share library.

A reconfiguring and recompiling of qt as share library and including mysql driver, not just as a plugin, solved the problem.

cheer
khikho

I request you to mention the commands used for reconfiguring of qt as share library and including mysql driver.

KaptainKarl
1st April 2011, 15:00
If you are wanting a static build:


# ./configure -platform linux-g++ -prefix /usr/local/qt-4.4-static -static -release -qt-sql-mysql -qt-sql-sqlite -I /usr/include/mysql -L /usr/lib/mysql

You can refer to http://doc.qt.nokia.com/4.4/install-x11.html for more details

Karl