PDA

View Full Version : Creating QMYSQL Driver



survi91
7th August 2013, 15:07
Dear All,

Let me just explain. Im creating an app for symbian smartphone using QT that will connect to remote DB (MYSQL) and update the table every certain time with coordinates received from GPS. I'm coming to a problem there is no QMYSQL driver installed thus I can't proceed. Only installed driver is QSQLITE. My question is, could I use QSQLITE driver to update tables ? It seems that using QSQLITE driver I can connect to DB, but can't do anything further (insert data to tables). Is it the QSQLITE that does not allow to insert that data or it could be code ?

Secondly, I tried to create my own QMYSQL driver as there are many tutorials out there. I was using few of them, but this one takes me the furthest : http://www.dreamincode.net/forums/topic/209154-qt-building-qmysql-with-mingw/

I'm getting into a problems when I execute mingw32-make. I get following messages:

Setting up environment for Qt usage...

C:\Qt\Qt5.1.0\5.1.0\mingw48_32>set PATH=C:\\QtSDK\\mingw\\bin

C:\Qt\Qt5.1.0\5.1.0\mingw48_32>set QTDIR=C:\\QtSDK\\QtSources\\4.8.1\\src\\plugi
ns\\sqldrivers\\mysql

C:\Qt\Qt5.1.0\5.1.0\mingw48_32>set QMAKESPEC=C:\\Qt\\4.8.5\\mkspecs\\win32-g++

C:\Qt\Qt5.1.0\5.1.0\mingw48_32>set mysqldir=C:\\MySQL\\MySQLServer55

C:\Qt\Qt5.1.0\5.1.0\mingw48_32>cd %mysqldir%\\lib

C:\MySQL\MySQLServer55\lib>reimp -d libmysql.lib

C:\MySQL\MySQLServer55\lib>dlltool -k -d libmysql.def -l libmysql.a

C:\MySQL\MySQLServer55\lib>cd %QTDIR%\\src\\plugins\\sqldrivers\\mysql
System nie moze odnalezc okreslonej sciezki.

C:\MySQL\MySQLServer55\lib>cd %QTDIR%

C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\my sql>qmake -o Makefile "INCLUDE
PATH+=%mysqldir%\\include" "LIBS+=%mysqldir%\\lib\\libmysql.a" mysql.pro

C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\my sql>mingw32-make
mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory `C:/QtSDK/QtSources/4.8.1/src/plugins/sqldri
vers/mysql'
g++ -c -pipe -O2 -Wall -Wextra -fno-exceptions -fno-rtti -DUNICODE -DQT_NO_CAST_
TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_COR
E_LIB -DQT_THREAD_SUPPORT -DQT_NO_DYNAMIC_CAST -I"r:\build\libs\qt-4.8.2.2012032
1\image-msvc2010-RelWithDebInfo-4.8.2\include\QtCore" -I"r:\build\libs\qt-4.8.2.
20120321\image-msvc2010-RelWithDebInfo-4.8.2\include\QtSql" -I"r:\build\libs\qt-
4.8.2.20120321\image-msvc2010-RelWithDebInfo-4.8.2\include" -I"c:\MySQL\MySQLSer
ver55\include" -I"r:\build\libs\qt-4.8.2.20120321\image-msvc2010-RelWithDebInfo-
4.8.2\include\ActiveQt" -I"release" -I"c:\Qt\4.8.5\mkspecs\win32-g++" -o release
\main.o main.cpp
main.cpp:42:30: error: qsqldriverplugin.h: No such file or directory
main.cpp:43:25: error: qstringlist.h: No such file or directory
In file included from main.cpp:44:
../../../sql/drivers/mysql/qsql_mysql.h:45:30: error: QtSql/qsqldriver.h: No suc
h file or directory
../../../sql/drivers/mysql/qsql_mysql.h:46:30: error: QtSql/qsqlresult.h: No suc
h file or directory
In file included from c:\MySQL\MySQLServer55\include/mysql.h:72,
from ../../../sql/drivers/mysql/qsql_mysql.h:52,
from main.cpp:44:
c:\MySQL\MySQLServer55\include/mysql_com.h:291: error: 'SOCKET' does not name a
type
c:\MySQL\MySQLServer55\include/mysql_com.h:470: error: 'SOCKET' was not declared
in this scope
c:\MySQL\MySQLServer55\include/mysql_com.h:470: error: expected primary-expressi
on before 'const'
c:\MySQL\MySQLServer55\include/mysql_com.h:470: error: expected primary-expressi
on before 'unsigned'
c:\MySQL\MySQLServer55\include/mysql_com.h:471: error: expected primary-expressi
on before 'unsigned'
c:\MySQL\MySQLServer55\include/mysql_com.h:471: error: initializer expression li
st treated as compound expression
In file included from main.cpp:44:
../../../sql/drivers/mysql/qsql_mysql.h:60: error: 'QT_BEGIN_HEADER' does not na
me a type
../../../sql/drivers/mysql/qsql_mysql.h:70: error: expected class-name before '{
' token
../../../sql/drivers/mysql/qsql_mysql.h:77: error: 'QVariant' does not name a ty
pe
../../../sql/drivers/mysql/qsql_mysql.h:84: error: 'QVariant' does not name a ty
pe
../../../sql/drivers/mysql/qsql_mysql.h:86: error: ISO C++ forbids declaration o
f 'QString' with no type
../../../sql/drivers/mysql/qsql_mysql.h:86: error: expected ',' or '...' before
'&' token
../../../sql/drivers/mysql/qsql_mysql.h:89: error: 'QVariant' does not name a ty
pe
../../../sql/drivers/mysql/qsql_mysql.h:90: error: 'QSqlRecord' does not name a
type
../../../sql/drivers/mysql/qsql_mysql.h:95: error: ISO C++ forbids declaration o
f 'QString' with no type
../../../sql/drivers/mysql/qsql_mysql.h:95: error: expected ',' or '...' before
'&' token
../../../sql/drivers/mysql/qsql_mysql.h:103: error: expected class-name before '
{' token
../../../sql/drivers/mysql/qsql_mysql.h:104: error: ISO C++ forbids declaration
of 'Q_OBJECT' with no type
../../../sql/drivers/mysql/qsql_mysql.h:105: error: expected ';' before 'friend'

../../../sql/drivers/mysql/qsql_mysql.h:107: error: expected ')' before '*' toke
n
../../../sql/drivers/mysql/qsql_mysql.h:108: error: 'QObject' has not been decla
red
../../../sql/drivers/mysql/qsql_mysql.h:110: error: 'DriverFeature' has not been
declared
../../../sql/drivers/mysql/qsql_mysql.h:111: error: ISO C++ forbids declaration
of 'QString' with no type
../../../sql/drivers/mysql/qsql_mysql.h:111: error: expected ',' or '...' before
'&' token
../../../sql/drivers/mysql/qsql_mysql.h:118: error: ISO C++ forbids declaration
of 'QSqlResult' with no type
../../../sql/drivers/mysql/qsql_mysql.h:118: error: expected ';' before '*' toke
n
../../../sql/drivers/mysql/qsql_mysql.h:119: error: 'QStringList' does not name
a type
../../../sql/drivers/mysql/qsql_mysql.h:120: error: 'QSqlIndex' does not name a
type
../../../sql/drivers/mysql/qsql_mysql.h:121: error: 'QSqlRecord' does not name a
type
../../../sql/drivers/mysql/qsql_mysql.h:122: error: 'QString' does not name a ty
pe
../../../sql/drivers/mysql/qsql_mysql.h:124: error: 'QVariant' does not name a t
ype
../../../sql/drivers/mysql/qsql_mysql.h:125: error: 'QString' does not name a ty
pe
../../../sql/drivers/mysql/qsql_mysql.h:127: error: expected ':' before 'Q_SLOTS
'
../../../sql/drivers/mysql/qsql_mysql.h:128: error: expected primary-expression
before 'bool'
../../../sql/drivers/mysql/qsql_mysql.h:128: error: ISO C++ forbids declaration
of 'Q_SLOTS' with no type
../../../sql/drivers/mysql/qsql_mysql.h:128: error: expected ';' before 'bool'
../../../sql/drivers/mysql/qsql_mysql.h:136: error: ISO C++ forbids declaration
of 'QMYSQLDriverPrivate' with no type
../../../sql/drivers/mysql/qsql_mysql.h:136: error: expected ';' before '*' toke
n
../../../sql/drivers/mysql/qsql_mysql.h:139: error: 'QT_END_NAMESPACE' does not
name a type
main.cpp:57: error: 'QMYSQLDriverPlugin' has not been declared
main.cpp:57: error: ISO C++ forbids declaration of 'QMYSQLDriverPlugin' with no
type
main.cpp: In function 'int QMYSQLDriverPlugin()':
main.cpp:58: error: only constructors take base initializers
main.cpp:60: warning: no return statement in function returning non-void
main.cpp: At global scope:
main.cpp:62: error: expected constructor, destructor, or type conversion before
'*' token
mingw32-make[1]: *** [release/main.o] Error 1
mingw32-make[1]: Leaving directory `C:/QtSDK/QtSources/4.8.1/src/plugins/sqldriv
ers/mysql'
mingw32-make: *** [release] Error 2

C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\my sql>


Could please someone help me ?????
Thanks

ChrisW67
7th August 2013, 23:51
My question is, could I use QSQLITE driver to update tables ? It seems that using QSQLITE driver I can connect to DB, but can't do anything further (insert data to tables). Is it the QSQLITE that does not allow to insert that data or it could be code ?
The Sqlite driver can manipulate Sqlite databases in all the ways you would expect. Sqlite databases are local files. The Sqlite driver cannot do anything with a MySql database whether local or remote.

You will need to build a MySql Qt plugin for your target platform (Symbian) as well as your desktop environment (if you want to test off-device).

Please edit your post to put all that machine output between
tags

survi91
9th August 2013, 00:49
Hmmm How do you edit posts ? :P

Also ... I don't need driver for the desktop, it's just the symbian ... Would you know how to do it ?

ChrisW67
9th August 2013, 01:52
AFAICT Qt5 is not supported on Symbian phones.
The pre-deployed Qt on Symbian phones is Qt 4.7 (maybe 4.8) and AFAICT does not include a MySql plugin.