View Full Version : Qt with MySql

15th July 2010, 02:11
Hello there,

I need to use MySql in Qt, and it's all good to go, classes, methods... except for one little thing... My program can't connect to MySql.

I have tried a lot of things, like following Qt doc, looking up in the internet, but nothing seems to work.
(I've tried finding threads in QtCentre forum, but I think I didn't find specifically my problem.... I think.)

Therefore, as a last resort, I'm humbly asking here if someone can point out what the heck I'm doing wrong...

Like the Doc says, I use configure as:
" configure -platform win32-g++ -static -release -qt-sql-sqlite -qt-sql-mysql -l mysql -I c:\mysql\include -L c:\mysql\lib\opt -fast "

(i haven't tried -plugin-sql-mysql instead of -qt-sql-sqlite but i don't think that's the problem)

and then run mingw32-make as the result of configure tells me to, after some 10 to 20 minutes i get :

g++ -enable-stdcall-fixup - Wl, -enable-auto-import -Wl, -enable-runtime-pseudo-reloc - Wl, -subsytem,console -mthreads -Wl -o ..\..\bin\rcc.exe tmp/obj/release_shared/rcc.0 tmp/obj/release_shared/main.o -lmysql -Lc:\mysql\lib\opt -L C:/Qt/2010.02.1/qt/src/tools/
bootstrap/release -lbootstrap -luser32 c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe
e: cannot find -lmysql
collect2: ld returned 1 exit status

mingw32-make[4]: *** [..\..\..\bin\rcc.exe] Error 1
mingw32-make[4]: Leaving directory C:/Qt/2010.02.1/qt/src/tools/rcc'
mingw32-make[3]: *** [release] Error 2
mingw32-make[3]: Leaving directory C:/Qt/2010.02.1/qt/src/tools/rcc'
mingw32-make[2]: *** [all] Error 2
mingw32-make[2]: Leaving directory C:/Qt/2010.02.1/qt/src/tools/rcc'
mingw32-make[1]: *** [sub-rcc-make-default-ordered] Error 2
mingw32-make[1]: Leaving directory C:/Qt/2010.02.1/qt
mingw32-make: *** [all] Error 2

Thank you for your time!

15th July 2010, 02:24
Is there a mysql library (libmysql.lib?) in "c:\mysql\lib\opt"?

15th July 2010, 08:22
Have you read this (http://www.qtcentre.org/wiki/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW) ?

16th July 2010, 23:27
Chris, yes, there is.
saa, I used a diferent tutorial, but it is kinda the same. I'll try it anyways and edit this message with what I managed to do.

Thank you both.

Yay, I finally managed to do it! Thank you!
(in the end, I forgot using
as well...)

I'll go bang my head against the wall about 50 times and come back to thank you again.


There, thank you.