Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QMYSQL driver not loaded - cross compiling for Raspberry PI 3
QtWS25 Last Chance

QMYSQL driver not loaded - cross compiling for Raspberry PI 3

Scheduled Pinned Locked Moved Solved Installation and Deployment
qmysqlcross compileraspberry pi 3
26 Posts 3 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JarekT
    wrote on 7 Jul 2020, 12:00 last edited by
    #1

    Dear All,

    I'm cross compiling my project for Raspberry PI 3 and it successful except that I cannot connect to MySql database. I got this standard error:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QSQLITE2 QODBC QODBC3 QPSQL QPSQL7 QTDS QTDS7

    Of course there are different threads that explain this but unfortunately this doesn't help...
    My host: Ubuntu 18.04
    Qt version that I use to cross compile for RPi3: 5.12.3
    Target: Raspberry PI 3

    Some time ago I was able to create the project (also on Ubuntu 18.04) and after some struggles I was able to connect to MySql. Unfortunately now I don't remember every single step I did... The project that I successfully run on the host, now I would like to run on RPi. I'm able to run the program on RPi but when I try to connect to the database I get the above error.

    I understand I need to have libqsqlmysql.so library. Unfortunately I don't have it:
    0d07f690-22d1-4cbb-b978-7a0ec280b4a4-image.png

    I downloaded sources for Qt5.12.3 from here. I understand I need to compile them so that I have the missing library. Am I right? Unfortunately I'm not able to do it.
    Here are some outputs that I get:
    313aaa2d-8495-49d2-919b-3ee9f85c37ec-image.png
    db52b366-f829-4e92-930f-683b7163f531-image.png

    8a126e26-9e17-44c6-ad38-4507a7f81264-image.png

    Could you also explain me what is actually the difference in removing the problem for regular compilation and cross compilation? Shouldn't I prepare the mysql driver on the target rather than on the host?

    I would be very happy to receive any suggestion...

    K 1 Reply Last reply 7 Jul 2020, 12:44
    0
    • J JarekT
      7 Jul 2020, 12:00

      Dear All,

      I'm cross compiling my project for Raspberry PI 3 and it successful except that I cannot connect to MySql database. I got this standard error:
      QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QSQLITE2 QODBC QODBC3 QPSQL QPSQL7 QTDS QTDS7

      Of course there are different threads that explain this but unfortunately this doesn't help...
      My host: Ubuntu 18.04
      Qt version that I use to cross compile for RPi3: 5.12.3
      Target: Raspberry PI 3

      Some time ago I was able to create the project (also on Ubuntu 18.04) and after some struggles I was able to connect to MySql. Unfortunately now I don't remember every single step I did... The project that I successfully run on the host, now I would like to run on RPi. I'm able to run the program on RPi but when I try to connect to the database I get the above error.

      I understand I need to have libqsqlmysql.so library. Unfortunately I don't have it:
      0d07f690-22d1-4cbb-b978-7a0ec280b4a4-image.png

      I downloaded sources for Qt5.12.3 from here. I understand I need to compile them so that I have the missing library. Am I right? Unfortunately I'm not able to do it.
      Here are some outputs that I get:
      313aaa2d-8495-49d2-919b-3ee9f85c37ec-image.png
      db52b366-f829-4e92-930f-683b7163f531-image.png

      8a126e26-9e17-44c6-ad38-4507a7f81264-image.png

      Could you also explain me what is actually the difference in removing the problem for regular compilation and cross compilation? Shouldn't I prepare the mysql driver on the target rather than on the host?

      I would be very happy to receive any suggestion...

      K Offline
      K Offline
      KroMignon
      wrote on 7 Jul 2020, 12:44 last edited by
      #2

      @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

      I would be very happy to receive any suggestion...

      First, I would suggest you to read documentation ==> https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

      Then, check MySQL or MariaDB shared libs and headers are installed on your platform.
      Rerun qmake

      J 1 Reply Last reply 7 Jul 2020, 14:01
      2
      • K KroMignon
        7 Jul 2020, 12:44

        @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

        I would be very happy to receive any suggestion...

        First, I would suggest you to read documentation ==> https://doc.qt.io/qt-5/sql-driver.html#how-to-build-the-qmysql-plugin-on-unix-and-macos

        Then, check MySQL or MariaDB shared libs and headers are installed on your platform.
        Rerun qmake

        J Offline
        J Offline
        JarekT
        wrote on 7 Jul 2020, 14:01 last edited by
        #3

        @KroMignon Thank you for your reply. Please tell me should I do it on target or on the host?

        The idea is to connect to the mysql installed on the target, so I think it should be done on the target. My MySQL database location is /var/lib, so I tried this:

        c61f7c61-7868-4f54-b05e-50d5843508cc-image.png

        but it looks like there is no qmake command available. I tried to find for any qmake file in the target:
        75fa9bd3-4fc7-43ea-b904-79ca70901f90-image.png

        K 1 Reply Last reply 7 Jul 2020, 14:41
        0
        • J JarekT
          7 Jul 2020, 14:01

          @KroMignon Thank you for your reply. Please tell me should I do it on target or on the host?

          The idea is to connect to the mysql installed on the target, so I think it should be done on the target. My MySQL database location is /var/lib, so I tried this:

          c61f7c61-7868-4f54-b05e-50d5843508cc-image.png

          but it looks like there is no qmake command available. I tried to find for any qmake file in the target:
          75fa9bd3-4fc7-43ea-b904-79ca70901f90-image.png

          K Offline
          K Offline
          KroMignon
          wrote on 7 Jul 2020, 14:41 last edited by
          #4

          @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

          Please tell me should I do it on target or on the host?

          On the target of course.
          Did you cross-compile Qt for you RPI or did you use a precompiled version?

          J 1 Reply Last reply 7 Jul 2020, 14:44
          0
          • K KroMignon
            7 Jul 2020, 14:41

            @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

            Please tell me should I do it on target or on the host?

            On the target of course.
            Did you cross-compile Qt for you RPI or did you use a precompiled version?

            J Offline
            J Offline
            JarekT
            wrote on 7 Jul 2020, 14:44 last edited by
            #5

            @KroMignon I did cross-compile according to this procedure: LINK

            K 2 Replies Last reply 7 Jul 2020, 14:53
            0
            • J JarekT
              7 Jul 2020, 14:44

              @KroMignon I did cross-compile according to this procedure: LINK

              K Offline
              K Offline
              KroMignon
              wrote on 7 Jul 2020, 14:53 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • J JarekT
                7 Jul 2020, 14:44

                @KroMignon I did cross-compile according to this procedure: LINK

                K Offline
                K Offline
                KroMignon
                wrote on 7 Jul 2020, 14:57 last edited by
                #7

                @JarekT So you have to add mysql libs on your RPI before creating the sysroot

                on RPI

                sudo apt-get install libmysqlclient-dev libmysqld-dev
                

                After that you should be able to cross-compile the plugin

                J 1 Reply Last reply 7 Jul 2020, 15:10
                1
                • K KroMignon
                  7 Jul 2020, 14:57

                  @JarekT So you have to add mysql libs on your RPI before creating the sysroot

                  on RPI

                  sudo apt-get install libmysqlclient-dev libmysqld-dev
                  

                  After that you should be able to cross-compile the plugin

                  J Offline
                  J Offline
                  JarekT
                  wrote on 7 Jul 2020, 15:10 last edited by JarekT 7 Jul 2020, 15:13
                  #8

                  @KroMignon When I tried to install those packages I got information that mariadb counterparts are available. So I tried to install them and it appeared that libmariadb-dev-compat,libmariadb-dev I already had, but libmariadbd-dev I didn't have so I installed it.

                  How can I cross-compile the plugin?

                  K 1 Reply Last reply 7 Jul 2020, 20:51
                  0
                  • J JarekT
                    7 Jul 2020, 15:10

                    @KroMignon When I tried to install those packages I got information that mariadb counterparts are available. So I tried to install them and it appeared that libmariadb-dev-compat,libmariadb-dev I already had, but libmariadbd-dev I didn't have so I installed it.

                    How can I cross-compile the plugin?

                    K Offline
                    K Offline
                    KroMignon
                    wrote on 7 Jul 2020, 20:51 last edited by
                    #9

                    @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                    How can I cross-compile the plugin?

                    After installing the missed packages, you have to recreate/update the sysroot.
                    Then restart qmake in the sqldrivers directory (I suppose RPI sysroot is located at /home/embsys/raspi/sysroot):

                    /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local
                    
                    make
                    make install
                    
                    J J 2 Replies Last reply 8 Jul 2020, 04:30
                    0
                    • K KroMignon
                      7 Jul 2020, 20:51

                      @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                      How can I cross-compile the plugin?

                      After installing the missed packages, you have to recreate/update the sysroot.
                      Then restart qmake in the sqldrivers directory (I suppose RPI sysroot is located at /home/embsys/raspi/sysroot):

                      /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local
                      
                      make
                      make install
                      
                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 8 Jul 2020, 04:30 last edited by
                      #10

                      @KroMignon said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                      Then restart qmake in the sqldrivers directory

                      I would suggest to do out of source builds to avoid problems with build artefacts from previous builds.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • K KroMignon
                        7 Jul 2020, 20:51

                        @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                        How can I cross-compile the plugin?

                        After installing the missed packages, you have to recreate/update the sysroot.
                        Then restart qmake in the sqldrivers directory (I suppose RPI sysroot is located at /home/embsys/raspi/sysroot):

                        /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local
                        
                        make
                        make install
                        
                        J Offline
                        J Offline
                        JarekT
                        wrote on 8 Jul 2020, 06:45 last edited by
                        #11

                        @KroMignon said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                        you have to recreate/update the sysroot

                        In the ~/raspi folder I did this (192.168.0.100 is IP of RPi):
                        rsync -avz pi@192.168.0.100:/lib sysroot
                        rsync -avz pi@192.168.0.100:/usr/include sysroot/usr
                        rsync -avz pi@192.168.0.100:/usr/lib sysroot/usr
                        rsync -avz pi@192.168.0.100:/opt/vc sysroot/opt

                        Is this what you meant by "you have to recreate/update the sysroot"?

                        After that I did qmake and I got the following results:
                        75f17afe-7dfe-451b-b5d2-097bd0b6605b-image.png

                        Unfortunately I don't see that MySql was configured...

                        Is the prefix "MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local" correct and is it enough?

                        @jsulm Before I did qmake I deleted whole src folder and extracted it again. Only then I did qmake. Is this what you meant?

                        K 1 Reply Last reply 8 Jul 2020, 06:58
                        0
                        • J JarekT
                          8 Jul 2020, 06:45

                          @KroMignon said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                          you have to recreate/update the sysroot

                          In the ~/raspi folder I did this (192.168.0.100 is IP of RPi):
                          rsync -avz pi@192.168.0.100:/lib sysroot
                          rsync -avz pi@192.168.0.100:/usr/include sysroot/usr
                          rsync -avz pi@192.168.0.100:/usr/lib sysroot/usr
                          rsync -avz pi@192.168.0.100:/opt/vc sysroot/opt

                          Is this what you meant by "you have to recreate/update the sysroot"?

                          After that I did qmake and I got the following results:
                          75f17afe-7dfe-451b-b5d2-097bd0b6605b-image.png

                          Unfortunately I don't see that MySql was configured...

                          Is the prefix "MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local" correct and is it enough?

                          @jsulm Before I did qmake I deleted whole src folder and extracted it again. Only then I did qmake. Is this what you meant?

                          K Offline
                          K Offline
                          KroMignon
                          wrote on 8 Jul 2020, 06:58 last edited by
                          #12

                          @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                          Is the prefix "MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local" correct and is it enough?

                          I don't really know, I don't have a RPI to test it.
                          But according to this post ==> https://raspberrypi.stackexchange.com/a/101366
                          You should probably use this:

                          /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf
                          
                          J 1 Reply Last reply 8 Jul 2020, 08:06
                          0
                          • K KroMignon
                            8 Jul 2020, 06:58

                            @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                            Is the prefix "MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/local" correct and is it enough?

                            I don't really know, I don't have a RPI to test it.
                            But according to this post ==> https://raspberrypi.stackexchange.com/a/101366
                            You should probably use this:

                            /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf
                            
                            J Offline
                            J Offline
                            JarekT
                            wrote on 8 Jul 2020, 08:06 last edited by
                            #13

                            @KroMignon I've changed the prefix but looks like it didn't help..

                            1ac29b64-8a32-4f97-852a-3f6a26e692cc-image.png

                            What can I do "remove any leftovers from the previous build" before I do reconfiguration?

                            J 1 Reply Last reply 8 Jul 2020, 08:09
                            0
                            • J JarekT
                              8 Jul 2020, 08:06

                              @KroMignon I've changed the prefix but looks like it didn't help..

                              1ac29b64-8a32-4f97-852a-3f6a26e692cc-image.png

                              What can I do "remove any leftovers from the previous build" before I do reconfiguration?

                              J Offline
                              J Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on 8 Jul 2020, 08:09 last edited by
                              #14

                              @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                              What can I do "remove any leftovers from the previous build" before I do reconfiguration?

                              Extract again the source code. To avoid this do out of source builds:

                              mkdir build
                              cd build
                              qmake PATH_TO_SOURCE
                              

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply 8 Jul 2020, 08:45
                              0
                              • J jsulm
                                8 Jul 2020, 08:09

                                @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                What can I do "remove any leftovers from the previous build" before I do reconfiguration?

                                Extract again the source code. To avoid this do out of source builds:

                                mkdir build
                                cd build
                                qmake PATH_TO_SOURCE
                                
                                J Offline
                                J Offline
                                JarekT
                                wrote on 8 Jul 2020, 08:45 last edited by
                                #15

                                @jsulm I've extracted again the sources. But I'm not sure if I understand what you meant by: "To avoid this do out of source builds". Do you mean that after I have newly extracted source code, I should always do the qmake in a new folder (eg. "build" as you mentioned) so that I do not affect the source code and in this way I can always do fresh compilation without the need to extract the source code files again?

                                Assuming that this is what you meant I did this:
                                0c2b3ccd-161b-48af-ba8f-3ab87a8755bc-image.png

                                As I can see mysql was not compiled... Could you please check if the paths and prefixes are correct?...

                                J 1 Reply Last reply 8 Jul 2020, 09:04
                                0
                                • J JarekT
                                  8 Jul 2020, 08:45

                                  @jsulm I've extracted again the sources. But I'm not sure if I understand what you meant by: "To avoid this do out of source builds". Do you mean that after I have newly extracted source code, I should always do the qmake in a new folder (eg. "build" as you mentioned) so that I do not affect the source code and in this way I can always do fresh compilation without the need to extract the source code files again?

                                  Assuming that this is what you meant I did this:
                                  0c2b3ccd-161b-48af-ba8f-3ab87a8755bc-image.png

                                  As I can see mysql was not compiled... Could you please check if the paths and prefixes are correct?...

                                  J Offline
                                  J Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on 8 Jul 2020, 09:04 last edited by
                                  #16

                                  @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                  I should always do the qmake in a new folder

                                  Yes.

                                  To check why it still does not work please see what is in configure.log file.

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  J 1 Reply Last reply 8 Jul 2020, 10:00
                                  0
                                  • J jsulm
                                    8 Jul 2020, 09:04

                                    @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                    I should always do the qmake in a new folder

                                    Yes.

                                    To check why it still does not work please see what is in configure.log file.

                                    J Offline
                                    J Offline
                                    JarekT
                                    wrote on 8 Jul 2020, 10:00 last edited by JarekT 7 Aug 2020, 10:02
                                    #17

                                    @jsulm Here is what I have in the config.log (I'm showing here only the part that contains information about the failures)

                                    b3572182-0f72-48a3-87cb-5f6a8ed4bafb-image.png

                                    Could you please help me understand those problems?

                                    K 1 Reply Last reply 8 Jul 2020, 10:13
                                    0
                                    • J JarekT
                                      8 Jul 2020, 10:00

                                      @jsulm Here is what I have in the config.log (I'm showing here only the part that contains information about the failures)

                                      b3572182-0f72-48a3-87cb-5f6a8ed4bafb-image.png

                                      Could you please help me understand those problems?

                                      K Offline
                                      K Offline
                                      KroMignon
                                      wrote on 8 Jul 2020, 10:13 last edited by
                                      #18

                                      @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                      Could you please help me understand those problems?

                                      Can you says which is the local path where you have put the sysroot? I supposed it was /home/embsys/raspi/sysroot.
                                      Then search in this path where is located libmysqlclient with find:

                                      find /home/embsys/raspi/sysroot -name libmysqlclient*.*
                                      

                                      Then use the path to configure/compile your plugin:

                                      /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=<lib_mysqlclient_path>
                                      
                                      J 1 Reply Last reply 8 Jul 2020, 10:23
                                      0
                                      • K KroMignon
                                        8 Jul 2020, 10:13

                                        @JarekT said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                        Could you please help me understand those problems?

                                        Can you says which is the local path where you have put the sysroot? I supposed it was /home/embsys/raspi/sysroot.
                                        Then search in this path where is located libmysqlclient with find:

                                        find /home/embsys/raspi/sysroot -name libmysqlclient*.*
                                        

                                        Then use the path to configure/compile your plugin:

                                        /home/embsys/raspi/qtbase/bin/qmake -- MYSQL_PREFIX=<lib_mysqlclient_path>
                                        
                                        J Offline
                                        J Offline
                                        JarekT
                                        wrote on 8 Jul 2020, 10:23 last edited by
                                        #19

                                        @KroMignon said in QMYSQL driver not loaded - cross compiling for Raspberry PI 3:

                                        Can you says which is the local path where you have put the sysroot? I supposed it was /home/embsys/raspi/sysroot.

                                        Yes, this is my sysroot. I did it as you can see below
                                        2027e562-be0c-446d-9197-b0c4ae8404a8-image.png

                                        This command I tried also before and the results are unsuccessful as before..
                                        Here I'm configuring/compiling the plugin using sqldriver.pro file, but I also read somewhere that mysql.pro (/home/embsys/raspi/qt-everywhere-src-5.12.3/qtbase/src/plugins/sqldrivers/mysql/mysql.pro) file should compiled. Do you know anything about it?

                                        1 Reply Last reply
                                        0
                                        • J Offline
                                          J Offline
                                          JarekT
                                          wrote on 8 Jul 2020, 10:59 last edited by JarekT 7 Aug 2020, 11:04
                                          #20

                                          Another idea: shouldn't I configure qmake itself before I try to use it to compile the plugin?

                                          That was my configure command when I was doing cross-compiling configuration (as in the LINK)

                                          ./configure -release -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -no-use-gold-linker -v -no-gbm

                                          The above doesn't include mysql feature (should it??)

                                          J 1 Reply Last reply 8 Jul 2020, 11:02
                                          0

                                          10/26

                                          8 Jul 2020, 04:30

                                          topic:navigator.unread, 16
                                          • Login

                                          • Login or register to search.
                                          10 out of 26
                                          • First post
                                            10/26
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved