PDA

View Full Version : QMYSQL driver not loaded



cydside
10th March 2010, 14:11
Hi to all,
yes I've read the previous posts about it but nothing match my problem. I've compiled the MySQL driver following the Qt guide "SQL Database Drivers". Then I've checked the folder "C:\Qt\2010.02\qt\plugins\sqldrivers" in order to confirm the library installed:



10/02/2010 19.01 2.168 libqsqlite4.a
10/02/2010 19.01 2.178 libqsqlited4.a
10/03/2010 14.28 2.182 libqsqlmysql4.a
10/03/2010 14.28 2.192 libqsqlmysqld4.a
10/02/2010 19.01 2.178 libqsqlodbc4.a
10/02/2010 19.01 2.182 libqsqlodbcd4.a
10/02/2010 19.01 478.720 qsqlite4.dll
23/02/2010 09.44 1.728.157 qsqlited4.dll
10/03/2010 14.28 113.152 qsqlmysql4.dll
10/03/2010 14.28 942.617 qsqlmysqld4.dll
10/02/2010 19.01 154.624 qsqlodbc4.dll
10/02/2010 19.01 943.815 qsqlodbcd4.dll

it seems to be ok!

So, I've tried to test a simple app subclassing a QWidget:



#include <QSqlDatabase>
#include <QDebug>
#include "Widget.h"
#include "ui_Widget.h"

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
}

Widget::~Widget()
{
delete ui;
}

void Widget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}


but my "Application Output" has reported:



Starting C:\Documents and Settings\D44\Desktop\testMySQL\debug\testMySQL.exe ...
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC


what is missing?

Thanks in advance

Lykurg
10th March 2010, 14:21
Have you also tried the "solutions" mentioned there under "Troubleshooting"? What does QApplication::libraryPaths() say?

cydside
10th March 2010, 14:28
Yes, I've tried:



qDebug() << QApplication::libraryPaths();


and returns:



("C:/Qt/2010.02/qt/plugins", "C:/Documents and Settings/D44/Desktop/testMySQL/debug")


It's correct!
Ok, panic: Aaaaaaaagh!

cydside
10th March 2010, 18:33
Hi to all again,
I've found the following tutorial:



http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/


where the guy who has wrote it talk about a lack in the Qt documentation. It seems that the tutorial on How to build MySQL libraries on Windows is working only for nmake (Visual Studio). Do you, according to you experience, confirm that?
Unbelievable!!!

GimpMaster
31st March 2010, 02:18
One thing I found with mine (Note: I am using MSVC compiler and I got the plugin to compile just fine) is that you also need the libmysql.dll file and located somewhere in your path. The libmysql.dll file is NOT included if you just install the mysql header and source files only the .lib and *.h files are. So I re-installed with the client programs and copyed the .dll to my executable folder and it works!