This is a post meant to be found on Google by people having the same problem, hopefully this will save them some time.

QSql Drivers

I spent at least 3 hours playing with QSql drivers, source code, DLLs and googling around in order to get rid of an annoying error :

alt text

After recompiling the qmysql drivers, therefore reinstalling MySQL & going through the pain of installing MS Visual Studio because it looked like Qt needed it to compile its qmysql driver (while it actually doesn’t ; you can compile it using MinGW) I was finally able to tackle the problem!

I finally got it to run smoothly by simply copying the libmysql.dll file from the MySQL C connector to the run folder of my application! Note that it didn’t even show up in “Dependency walker” that it needed some more DLLs.

I could have kept recompiling for hours to no avail!

BTW, in order to compile the QMySQL driver, it is best to take a good old MySQL Community Server 5.1, and install only the developer components “C Include Files / Lib Files”. Then one can simply use the MinGW Qt Command prompt and do inside Src\qtbase\src\plugins\sqldrivers\mysql the following:

qmake "INCLUDEPATH+=C:/MySQL/MySQL51/include" "LIBS+=C:/MySQL/MySQL51/lib/opt/libmysql.lib"

et voilĂ , you’ll get a nice pair of dll inside Src\qtbase\plugins\sqldrivers.