How to install MySql driver plugin in QT SDK 4.7 (2010.05)?
-
Can you be more specific with problems?
-
Sure.
First of all: "Look at this link":http://christopher.rasch-olsen.no/2009/04/14/qt-45-and-mysql-plugin-with-mingw-on-windows-xp/
When I followed these instructions on my laptop (WINDOWS VISTA HOME PREMIUM) at home everything worked fine using QT 2010.02 SDK version installed (a few months ago).
Then at work, I downloaded the last available version QT 2010.05, installed on my desktop PC (WINDOWS XP) and tried to repeat exactly the same steps but unsuccessfully.
Downloaded mingw-utils-0.3 and copied all the bin content into C:\Qt\2010.05\mingw\bin.
One problem is: I could't run "mingw32-make clean" because there is no Makefile in qt\qmake dir.
So, I ran configure under qt dir. and let it create all the Makefiles.
Next steps:- run mingw32-make confclean (as suggested by the configure utility) and
configure -debug-and-release -plugin-sql-mysql. - cd src\plugins\sqldrivers\mysql.
- set MYSQL_PATH=c:\MySQL.
- reimp -d %MYSQL_PATH%\lib\opt\libmysql.lib.
- dlltool -k --input-def LIBMYSQL.def --dllname libmysql.dll --output-lib libmysql.a.
- qmake "INCLUDEPATH+=%MYSQL_PATH%include" "LIBS+=-L. -lmysql" mysql.pro
- under qt dir. run mingw32-make sub-src.
After a couple of hours I got these errors:
@C:\Qt\2010.05\qt\bin\moc.exe -DQT_SHARED -DQT_THREAD_SUPPORT -DUNICODE -DQT_LARG
EFILE_SUPPORT -DJSC=QTJSC -Djscyyparse=qtjscyyparse -Djscyylex=qtjscyylex -Djscy
yerror=qtjscyyerror -DWTF=QTWTF -DQT_BUILD_SCRIPT_LIB -DQT_NO_USING_NAMESPACE -D
QLALR_NO_QSCRIPTGRAMMAR_DEBUG_INFO -DQT_MAKEDLL -DQT_NO_CAST_TO_ASCII -DQT_ASCII
CAST_WARNINGS -DQT3_SUPPORT -DQT_MOC_COMPAT -DQT_USE_FAST_OPERATOR_PLUS -DQT_US
E_FAST_CONCATENATION -D_USE_MATH_DEFINES -DBUILDING_QT_=1 -DWTF_USE_ACCELERATED
COMPOSITING -DUSE_SYSTEM_MALLOC -DBUILDING_QT_ -DBUILDING_JavaScriptCore -DBUI
LDING_WTF -DWTF_USE_JAVASCRIPTCORE_BINDINGS=1 -DWTF_CHANGES=1 -DNDEBUG -DJS_NO_E
XPORT -DQT_DLL -DQT_CORE_LIB @tmp/moc/debug_shared/mocinclude.tmp -D__GNUC__ -DW
IN32 api\qscriptextensionplugin.h -o tmp\moc\debug_shared\moc_qscriptextensionpl
ugin.cpp
api\qscriptextensionplugin.h:43: Error: Undefined interface
mingw32-make[2]: *** [tmp/moc/debug_shared/moc_qscriptextensionplugin.cpp] Error 1
mingw32-make[2]: Leaving directoryC:/Qt/2010.05/qt/src/script' mingw32-make[1]: *** [debug-all] Error 2 mingw32-make[1]: Leaving directory
C:/Qt/2010.05/qt/src/script'
mingw32-make: *** [sub-script-sub_src_target_ordered] Error 2@My PATH is: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Common Files\Lenovo;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Roxio Shared\DLLShared;C:\Program Files\Common Files\Roxio Shared\10.0\DLLShared;C:\Program Files\Lenovo\Client Security Solution;C:\Program Files\Intel\DMIX;C:\Program Files\Diskeeper Corporation\Diskeeper;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\IVI Foundation\VISA\WinNT\Bin;C:\Program Files\IVI Foundation\IVI\bin;C:\PROGRA~1\IVIFOU~1\VISA\WinNT\Bin;C:\Program Files\IVI Foundation\VISA\WinNT\Bin;C:\pvb\win-mingw\bin;C:\Qt\2010.05\qt\bin;C:\Qt\2010.05\mingw\bin;C:\MySQL\bin.
- run mingw32-make confclean (as suggested by the configure utility) and
-
At the step 7 try to run make from the mysql plugin sources dir
-
Blex,
Can I have an explanation for your request?
-
I do not compile mysql driver myself but I guess that the following may help:
After running step 6 you will get Makefile in the %QTDIR%\src\plugins\sqldrivers\mysql\ directory
Go to this directory and try to execute "make", or "mingw32-make"
Your build fails on the step not related to mysql compilation.
-
I understand your point but If the original binaries coming along with SDK have been compiled using a different version of mingw or a different configuration, this probably won't work.
-
Just for clarification: I suppose that you do all steps 1-7 from your instruction above with changes in according to my post.
mingw used for SDK build is not important to you, only Qt. Try to recompile Qt from sources. On modern PC it takes not more than 2 hours. You can pass to configure.exe the switches to include mysql plugin.
Probably, it is better to download qt sources separately and build them in other directory. After that just tell QtCreator what Qt version should be used.
-
OK, blex. I'll try your idea first and if it doesn't fix the problem I will try downloading qt sources separately and build them. I will let you know the result.
Only another question: how can I tell QtCreator what Qt version should be used?
Thanks a lot for your time.
-
[quote author="blueyes" date="1291357867"]Only another question: how can I tell QtCreator what Qt version should be used?[/quote]
Anfortunately, I have localized UI on my PC, so, maybe English menus are slightly different: use Tools - Options - Qt4 - Qt versions
-
I've updated the article from "pikopong":http://www.pikopong.com/blog/2010/04/11/how-to-enable-mysql-support-in-qt-sdk-for-windows/ with some additional information. But the guide still works, I've tested it in my Virtual Box with a clean Windows XP (never install Qt or MySQL before in it). You can see the full build process "here":http://pastie.org/1348501
-
The problem aurorius is, as I already said before, that this way I can build the driver but NOT the test application:
@#include <QtGui/QApplication>
#include <QCoreApplication>
#include <QDebug>
#include <QtSQL/QSqlDatabase>
#include "mainwindow.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qDebug() << QSqlDatabase::drivers();return a.exec();
}@
Here are the errors I got:
@Running build steps for project SqlTest...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Paolo/QtPtojects/SqlTest-build-desktop'C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Paolo/QtPtojects/SqlTest-build-desktop'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\SqlTest.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\Qt\2010.05\qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Paolo/QtPtojects/SqlTest-build-desktop'
mingw32-make: Leaving directory `C:/Paolo/QtPtojects/SqlTest-build-desktop'
debug/main.o: In function `Z5qMainiPPc':
C:\Paolo\QtPtojects\SqlTest-build-desktop/../SqlTest/main.cpp:10: undefined reference to '_imp___ZN12QSqlDatabase7driversEv'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\SqlTest.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project SqlTest (target: Desktop)
When executing build step 'Make'@ -
Just in case if you're wondering, this is the compile output for a working project
@Running build steps for project testmysql...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Documents and Settings/root/My Documents/Projects/testmysql-build-desktop'C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Documents and Settings/root/My Documents/Projects/testmysql-build-desktop'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.05\qt\include\QtCore" -I"c:\Qt\2010.05\qt\include\QtSql" -I"c:\Qt\2010.05\qt\include" -I"c:\Qt\2010.05\qt\include\ActiveQt" -I"debug" -I"..\testmysql" -I"." -I"c:\Qt\2010.05\qt\mkspecs\win32-g++" -o debug\main.o ..\testmysql\main.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\testmysql.exe debug/main.o -L"c:\Qt\2010.05\qt\lib" -lQtSqld4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Documents and Settings/root/My Documents/Projects/testmysql-build-desktop'
mingw32-make: Leaving directory `C:/Documents and Settings/root/My Documents/Projects/testmysql-build-desktop'
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited normally.@
-
Eventually I've been able to figure out why it didn't build: I had to manually add to the .pro file the SQL module.
QT += core gui sql
Now it works!
Many thanks again for the support.
-
[quote author="blueyes" date="1291600372"]Eventually I've been able to figure out why it didn't build: I had to manually add to the .pro file the SQL module.
QT += core gui sql
Now it works!
Many thanks again for the support.[/quote]
Next time read proper documentation. Paragraph modules. where write such "if you using sql write QT += sql", "If you using GUI, write QT += gui", etc..
-
hi all...
I am using ubuntu OS ..and I install Qt via downloading it from QT center.When I wrote this code I found only one driver that is "QSQLITE".
so how to install that I can work with QMYSQL driver -
You've got to configure an build Qt with the QMYSQL Database driver enabled.