MySQL support for Qt 5.1.1
-
Thanks for the reply.. and sorry to respond late.
Well.. we need the Mysql server running in a different machine and the Qt application is to be used in an embedded environment with low memory footprint.In this case what would be the best way I can pull values from the Mysql tables.
-
I suppose the embedded device will connect to the server through internet ?
If so, you should rather use a web service for your device to communicate with the database.
-
Ok.. I have created an application using Qt Quick and using qml files hoping to have a low memory utilization.
I am looking around for help in Qt. What would you suggest how should I be implementing the webservice call in this context? Is that should be handled in the application or in the qml file?
Any reference on this will be very helpful.Thanks.
-
And also, part of learning Qt, I wanted to rebuild the mysql plugin as you have mentioned. However friend of mine had the .run file to install Qt in the system as I told before.
sudo -s chmod u+x ./qt-linux-opensource-5.1.1-x86-offline.runThat does not have the source code within.
Therefore I downloaded Qt 5.1.1 source code from the below link, the tgz file
http://mirrors.sohu.com/qt-all/official_releases/qt/5.1/5.1.1/single/And tried to build the plugin using already installed qmake binary file as below.
/home/test/Downloads/Qt/qt-everywhere-opensource-src-5.1.1/qtbase/src/plugins/sqldrivers/psql/psql.pro INCLUDEPATH+=/usr/lib/i386-linux-gnu LIBS+=-L/usr/lib/i386-linux-gnu\ -lmysqlclient_r -o Makefile ) && make -f Makefile
But got the following error message.
../../../sql/drivers/psql/qsql_psql.cpp:59:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
make[1]: *** [.obj/release-shared/qsql_psql.o] Error 1
make[1]: Leaving directory `/home/test/Downloads/Qt/qt-everywhere-opensource-src-5.1.1/qtbase/src/plugins/sqldrivers/psql'
make: *** [sub-psql-make_first] Error 2Could you please help me resolve this.
Is there a problem if I use the qmake from my first installation or do I require to build qmake from the downloaded source code?Thanks
-
You are not building the MySQL plugin but the PostgreSQL
For the web service part have a look at "libQxt":http://libqxt.org/ they provide some nice classes to help implement that
Edit: link corrected
-
Thank you very much Sam. I was able to build the plugin for mysql.
And the link provided for web service seems disconnected. Could you please check this.Thanks
-
You're welcome !
I've corrected the link
-
I have the plugin built and copied it from
Qt/qt-everywhere-opensource-src-5.1.1/qtbase/plugins/sqldrivers
to /opt/Qt5.1.1/5.1.1/gcc/plugins/sqldrivers
Renamed the old libqsqlmysql.so to back_libqsqlmysql.so in the same folder.lddtree results of the one copied is below:
lddtree libqsqlmysql.so
libqsqlmysql.so => ./libqsqlmysql.so (interpreter => none)
libmysqlclient.so.18 => /usr/lib/i386-linux-gnu/libmysqlclient.so.18
libz.so.1 => /lib/i386-linux-gnu/libz.so.1
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2
ld-linux.so.2 => /lib/i386-linux-gnu/ld-linux.so.2
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0
libm.so.6 => /lib/i386-linux-gnu/libm.so.6
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1
libQt5Sql.so.5 => /opt/Qt5.1.1/5.1.1/gcc/lib/libQt5Sql.so.5
libQt5Core.so.5 => /opt/Qt5.1.1/5.1.1/gcc/lib/libQt5Core.so.5
libicui18n.so.51 => not found
libicuuc.so.51 => not found
libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0
librt.so.1 => /lib/i386-linux-gnu/librt.so.1
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6
libc.so.6 => /lib/i386-linux-gnu/libc.so.6Please note that libicui18n.so.51 and libicuuc.so.51 do not have any sym links found.
I am still getting the error when running the pgm.
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QMYSQL QMYSQL3 QSQLITE QPSQL QPSQL7
false
QSqlQuery::exec: database not openPlease tell me where did I go wrong.
Thanks.
-
Forgot to mention that added the newly compiled libqsqlmysql.so into the project pro file
LIBS += libqsqlmysql.so
And mentioned the path in the Makefile
LIBS = $(SUBLIBS) -L/opt/Qt5.1.1/5.1.1/gcc/plugins/sqldrivers/libqsqlmysql.so -
if it can't find libicu it won't load the plugin. It should be somewhere in /opt/Qt5.1.1/5.1.1/