I\'m trying to access a MySql database from a Qt application but I get the following error:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available dr
I compiled QT first and then realised that I need mysql as well. So I compiled mysql plugin by executing following command in QT-DIR\src\plugins\sqldrivers\mysql folder.
qmake "INCLUDEPATH+=$$quote(C:\Program Files\MySQL\MySQL Server 5.5\include)" "LIBS+=$$quote(C:\Program Files\MySQL\MySQL Server 5.5\lib\libmysql.lib)" mysql.pro
Plugings are then created in created in folder QT-DIR\plugins\sqldrivers. However, when I tried to use it in my code. It failed with following error.
QSqlDatabase: QMYSQLDriver driver not loaded
After some googling and checking Path variable I realised that the Mysql server lib ( C:\Program Files\MySQL\MySQL Server 5.5\lib) directory was not in my Path variable. I expect that the dll in this folder are used by the plugin at runtime. After including Mysql server lib in Path variable everything worked smoothly. Hope this information saves some hair on other programmers scalp, as I uprooted quite a few. :D