PDA

View Full Version : QSqlDatabase: QMYSQL driver not loaded



RSX
6th April 2009, 23:30
I'm getting this error when executing my program:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC3 QODBC

I tried compiling mysql (in the same way as it's shown in documention for SQLite) but I'm getting there errors aswell.

Any suggestions?

spirit
7th April 2009, 06:21
did you try to search by forum? take a look at this (http://www.qtcentre.org/forum/search.php?searchid=710136) search result.

lyuts
7th April 2009, 09:10
Do you have MySQL installed?



cd $QTDIR/src/plugins/sqldrivers/mysql
qmake "INCLUDEPATH+=-I<mysql_installation_path>/include" "LIBS+=-L<mysql_installation_path>/lib -lmysqlclient_r" mysql.pro
make


If this fails, you will need to show us the errors.

RSX
7th April 2009, 19:21
lyuts,


In file included from main.cpp:40:
../../../sql/drivers/mysql/qsql_mysql.h:48:19: mysql.h: No such file or directory
In file included from main.cpp:40:
../../../sql/drivers/mysql/qsql_mysql.h:103: error: expected `)' before '*' token
mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1


spirit, yes I did, but in other thread the creator of it had installed MySQL. When I list all allowed drivers, MySQL is not there.

lyuts
8th April 2009, 08:00
So, as I understand you don't have MySQL installed. You need MySQL headers and libs installed in order to build this sql driver. Install them first and only then try to build mysql plugin.

miksa007
14th April 2009, 07:09
In ubuntu: the first install "MySQL database development" files with apt-get or synaptic or...

Then:
cd $QTDIR/src/plugins/sqldrivers/mysql

qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro

make

check the include path, because my path was different: qmake "INCLUDEPATH+=/usr/include/mysql/" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro
If the path is wrong the file mysql.h never found.

some information:
http://doc.trolltech.com/4.5/sql-driver.html#supported-databases

miksa007
28th April 2009, 06:58
How to get MySQL driver to work in Ubuntu

ubuntu:~$ cd qtsdk-2009.02/qt/

ubuntu:~$ touch LICENSE.GPL3 LICENSE.LGPL

ubuntu:~$ ./configure -plugin-sql-mysql
ubuntu:~$ make

if ”qgtkstyle error” occurs, install gtk dev pagcages using apt-get (apt-get install qt4-dev-tools gtkgl-dev gtkglarea5-dev libqt4-dev libgtk2.0-dev)

ubuntu:~$ make install
it takes 1-3 hours.