I have successfully compiled the MySQL drivers, but I cannot force Qt to load them.
What should be said in the beginning Iv got ODBC and SQLite drivers with the package (after installing Qt) and they are not detected either.
In *C:\Qt\4.8.0\plugins\sqldrivers* Iv got:
qsqlite4.dll
qsqlite4.lib
qsqlited4.dll
qsqlited4.lib
qsqlmysql4.dll
qsqlmysql4.lib
qsqlmysqld4.dll
qsqlmysqld4.lib
qsqlodbc4.dll
qsqlodbc4.lib
qsqlodbcd4.dll
qsqlodbcd4.lib
qsqlpsql4.dll
qsqlpsql4.lib
qsqlpsqld4.dll
qsqlpsqld4.lib
The qsqlmysql*.* files I have also put in:
C:\Qt\4.8.0\bin
APPLICATION\
APPLICATION\Debug\
APPLICATION\Release\
APPLICATION\sqldrivers\
Of course Iv got QtSql*.dll also in place.
Iv got .pro properly configured:
QT += core gui network sql
And I'm running this code:
#include <QSqlRecord>
#include <QSqlError>
QLibrary mysqllib("qsqlmysqld4.dll");
mysqllib.load();
auto t1 = mysqllib.isLoaded();
qDebug()<<"my library loaded"<<mysqllib.isLoaded();
QPluginLoader plug("qsqlmysqld4.dll");
plug.load();
auto t2 = plug.isLoaded();
qDebug()<<"mysql plugin is loaded"<<plug.isLoaded();
ui->textEditContent->append( "--SQL DRIVERS SUPPORTED:--\n" );
FOREACH( auto driver, QSqlDatabase::drivers() )
ui->textEditContent->append( " " + driver + "\n" );
QLibrary and QPluginLoader returns true. And QSqlDatabase::drivers() is empty. What I'm doing wrong? None of the drivers in C:\Qt\4.8.0\plugins\sqldrivers are seen by Qt. Iv compiled Qt and SQL drivers with same compiler (MSVC2010), without errors. I'm running my code for several months. The task was to add MySQL support.