How to add QMySQL driver for Raspberry Pi?
-
wrote on 5 Oct 2016, 07:08 last edited by
Hi.
I'm trying to install QMySQL driver on Raspberry Pi 3.
I use cross-compile environment on Ubuntu 16.04 64bit.
I can access remote MySQL database with Desktop kit option but can't with Raspberry pi kit.
The error message are as follows:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITEI found that I need to add MySQL driver for RPI or re-configure whole things with mysql options such as 'qt-sql-mysql' etc,.
But I couldn't find a proper solution.I would appreciate if you give me any advice or tutorials.
Thanks.
-
Hi and welcome to devnet,
No you don't have to recompile all of Qt. You can simply build the MySQL driver as long as you have the MySQL client libraries installed on your RPI3. You can then follow this guide.
Hope it helps
-
Hi and welcome to devnet,
No you don't have to recompile all of Qt. You can simply build the MySQL driver as long as you have the MySQL client libraries installed on your RPI3. You can then follow this guide.
Hope it helps
wrote on 6 Oct 2016, 09:16 last edited by JamesDin 10 Jul 2016, 00:04@SGaist
Hi.
First, Thank you for your reply.I followed your link and read the post carefully.
I tried to do that instruction(sub title is "How to Build the QMYSQL Plugin on Unix and OSX) line by line but
there are somethings that I can't understand. Please refer to the image below (I commented my opinion). -
Currently the image upload function is broken, can you use an image sharing site.
See here on how to include the image in your post.
-
Currently the image upload function is broken, can you use an image sharing site.
See here on how to include the image in your post.
-
Seems like you didn't install the MySQL client libraries on your RPi3.
If you can't find the mysql.pro file it's likely that you didn't download Qt's sources.
-
Seems like you didn't install the MySQL client libraries on your RPi3.
If you can't find the mysql.pro file it's likely that you didn't download Qt's sources.
wrote on 10 Oct 2016, 00:33 last edited by JamesDin 10 Oct 2016, 04:54I installed MySQL client libraried on my RPI3. libmysqlclient.so file could be found.
And I didn't download Qt sources like you said.
Because I thought that the MySQL driver for RPI would be made by cross-compilation.
(MySQL driver for RPI is built on linux machine and is transferd into RPI.)
Should I have both Qt source and MySQL client libraries in RPI3 and follow above instructions for building driver? -
My bad, I forgot you cross-compiled so you already should have the sources for that.
If the MySQL dev package wasn't installed when cross-compiling Qt, then the driver won't be built. You can however follow the documentation by using the qmake from your cross-compiled Qt and the path to the sysroot where the libraries/headers can be found.
-
My bad, I forgot you cross-compiled so you already should have the sources for that.
If the MySQL dev package wasn't installed when cross-compiling Qt, then the driver won't be built. You can however follow the documentation by using the qmake from your cross-compiled Qt and the path to the sysroot where the libraries/headers can be found.
-
You're welcome !
What was the problem in the end ?
-
wrote on 11 Oct 2016, 08:24 last edited by JamesDin 10 Nov 2016, 08:25
I did 'qmake' that was created by cross-compilation as your guide.
After that, compiled MySQL driver was copied into mounted RPI image.
My mistake is that I understood instruction is need to be done on RPI. -
Cross-compilation is a tricky subject.
Happy coding ! :)
-
I did 'qmake' that was created by cross-compilation as your guide.
After that, compiled MySQL driver was copied into mounted RPI image.
My mistake is that I understood instruction is need to be done on RPI.wrote on 6 Jun 2017, 07:33 last edited by andquesada 6 Jun 2017, 07:34Hi!
So I followed the instructions here to cross-build a MySql driver. I have the same environment as you but I get this error:
Project ERROR: Library 'mysql' is not defined.I am using Ubuntu Mate on my Raspberry Pi 3.
mysql_config --include says -I/usr/include/mysql
mysql_config --libs says -L/usr/lib/arm-linux-gnueabihf -lmysqlclient -lpthread -lz -lm -lrt -ldlSo the line to compile I am using is:
${CROSS_BUILT_QMAKE}/./qmake "INCLUDEPATH+=${SYSROOT}/usr/include/mysql" "LIBS+=-L${SYSROOT}/usr/lib/arm-linux-gnueabihf -lmysqlclient_r" mysql.proAny help would be appretiated.
Thank you!
-
wrote on 25 Jun 2017, 11:22 last edited by
@SGaist
Hello, I am new in Qt programming, I have the same situation as sir @andquesada . When i want to qmake the sql driver, the output is : Project ERROR: Library 'mysql' is not defined.Hope that you can help us. Thx
-
Which version of Qt are you trying to build ?