Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Compiling QMYSQL on Windows with VS2010 [SOLUTION]
maxx1985 last edited by
I've got a lot of touble finding the solution of this problem, the guide on the official doc (http://qt-project.org/doc/qt-4.8/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows), is too sintetic, i needed something more, a lot of the tutorial on the web says different things, here my version of the solution, i hope it can help!
- Windows 7 x64 and x32 (Both tested)
- Visual Studio 2010 Professional and Ultimate (Both Tested)
- QT version 4.8.3
- MySql version 5.1.72, zip noistall version (mysql-noinstall-5.1.72-win32.zip google is your friend :))
- Path used of MySql *C:\Qt\mysql1*
- Path used of QT sdk *C:\Qt\483*
Frist of all unpack your mysql archive, install qt and the creator, check that all is working.
I needed also to disable the antivirus (avast in my case)
Add the following path variable to the PATH:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
*C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools*
(The VS path my be not strongly necessary, but i've did it this way)
If your setup path are differnet from mine, just be sure that there are NO SPACES,
C:\Program Files\MySQL Server ---> WRONG
C:\Progra~1\MySQL~1 ----> CORRECT (~ is a tilde sign, the vawe sign)
If your folder three is more complicated to know the exact 8.3 naming format of your folder tree, you can use the command dir /x from the command prompt of windows
All include path must ave no spaces and at least a 8.3 naming format, or it will not work
(And not like the misleading qt documentation that write "LIBS+=C:\MYSQL*MySQL Server <version>*\lib\opt\libmysql.lib" with spaces)
Reboot the pc, just to be sure.
Let's start the real job
Let's start opening the VisualStudio 2010 command promt, the standard version (not the x64, not the itanium) usually on
start > Programs > Microsoft Visual Studio 2010 > Visual Studio Tools
Now go in the followning dir (according to my setup, you can modify the path according to your setup)
now lunch the followin commands (also according to my setup):
@qmake “INCLUDEPATH+=C:\Qt\mysql1\include” “LIBS+=-LC:\Qt\mysql1\lib\opt\ -llibmysql” mysql.pro
nmake //debug lib compile
nmake release //release lib compile@
It should go without errors, now you have the coveted dll. files
(the double \ are needed to avoid some warning, also check the apex (") in the command, the forum charset my screw them up!)
now, you have to put the files form the release (C:\Qt\483\src\plugins\sqldrivers\mysql\release) dir and the debug dir (C:\Qt\483\src\plugins\sqldrivers\mysql\debug) to the following path
you will add the following files:
and from C:\Qt\mysql1\lib\opt
you wil put in c:\windows the file libmysql.dll
You are now done and you can start any debug code for check yourself if the whole thing work.
If your current setup are matching mine, you can try to download my compiled library! These lib are not garanted to work but if you want give a try no problem for me!
I hope this tutorial can help a lot of pepole who had the same problem.
I'll be glad to hear any suggestion and i'm sorry for my not so brillant english :D