RubyPDF Blog Qt How to build the QMYSQL plugin under Windows using MinGW

How to build the QMYSQL plugin under Windows using MinGW

I have installed QT4.6.3(2010.04, install path is D:\Qt\2010.04), and want to integrate mysql support into my new project, so I need to build qmysql plugin first.
prepare job,
download mysql-noinstall-5.1.49-win32.zip and unzip to D:\basetool\MySQL-5.1.49-win32
download mingw-utils-0.3 and unzip to D:\Qt\2010.04\mingw\bin

run Qt Command Prompt, and execute the following script
cd D:\basetool\MySQL-5.1.49-win32\lib\opt
reimp -d libmysql.lib
dlltool -k --input-def LIBMYSQL.def --dllname libmysql.dll --output-lib libmysql.a
copy libmysql.a D:\Qt\2010.04\qt\src\plugins\sqldrivers\mysql
cd D:\Qt\2010.04\qt\src\plugins\sqldrivers\mysql
set MYSQL_PATH=D:\basetool\MySQL-5.1.49-win32\
qmake "INCLUDEPATH+=%MYSQL_PATH%include" "LIBS+=-L. -lmysql" mysql.pro
mingw32-make
copy D:\basetool\MySQL-5.1.49-win32\lib\opt\libmysql.dll D:\Qt\2010.04\mingw\bin

Test the demo sqlbrowser(in the D:\Qt\2010.04\qt\demos\sqlbrowser), and works.

P.S.
first time I downloaded mingw-utils-0.4-1, and when run the command “reimp -d libmysql.lib”,I got the error message
reimp: libmysql.lib: invalid or corrupt import library
after search , I knew, have to use mingw-utils-0.3, the version 0.4-1 does not work and report the error message.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.