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

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.2k 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 JarekT
    8 Jul 2020, 10:59

    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 Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 8 Jul 2020, 11:02 last edited by
    #21

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

    shouldn't I configure qmake itself

    What do you want to configure?

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

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

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

      shouldn't I configure qmake itself

      What do you want to configure?

      J Offline
      J Offline
      JarekT
      wrote on 8 Jul 2020, 11:09 last edited by
      #22

      @jsulm Sorry if the way I explained it was not correct. I meant that when I was preparing the framework for cross-compilation in the folder /home/embsys/raspi/qtbase I did

      ./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

      Should it contain something about mysql?

      J 1 Reply Last reply 8 Jul 2020, 11:12
      0
      • J JarekT
        8 Jul 2020, 11:09

        @jsulm Sorry if the way I explained it was not correct. I meant that when I was preparing the framework for cross-compilation in the folder /home/embsys/raspi/qtbase I did

        ./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

        Should it contain something about mysql?

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 8 Jul 2020, 11:12 last edited by
        #23

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

        Should it contain something about mysql?

        It should be possible to build MySQL related stuff after compiling Qt.

        Did you search for libmysqlclient* as @KroMignon suggested to make sure you pass correct paths?

        Also, please post text instead of screen-shots.

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

        J 1 Reply Last reply 8 Jul 2020, 11:21
        0
        • J jsulm
          8 Jul 2020, 11:12

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

          Should it contain something about mysql?

          It should be possible to build MySQL related stuff after compiling Qt.

          Did you search for libmysqlclient* as @KroMignon suggested to make sure you pass correct paths?

          Also, please post text instead of screen-shots.

          J Offline
          J Offline
          JarekT
          wrote on 8 Jul 2020, 11:21 last edited by
          #24

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

          Did you search for libmysqlclient* as @KroMignon suggested to make sure you pass correct paths?

          Yes, the paths for libmysqlclient.. is correct.

          embsys@JT-UBUNTU:~/qmakeBuild$ find /home/embsys/raspi/sysroot -name libmysqlclient*.*
          /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient.a
          /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient_r.so
          /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient.so
          /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient_r.a
          

          Ok, I will try to post text instead of screen-shots.

          J 1 Reply Last reply 10 Jul 2020, 16:27
          0
          • J JarekT
            8 Jul 2020, 11:21

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

            Did you search for libmysqlclient* as @KroMignon suggested to make sure you pass correct paths?

            Yes, the paths for libmysqlclient.. is correct.

            embsys@JT-UBUNTU:~/qmakeBuild$ find /home/embsys/raspi/sysroot -name libmysqlclient*.*
            /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient.a
            /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient_r.so
            /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient.so
            /home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf/libmysqlclient_r.a
            

            Ok, I will try to post text instead of screen-shots.

            J Offline
            J Offline
            JarekT
            wrote on 10 Jul 2020, 16:27 last edited by
            #25

            I'm constantly trying to solve the issue... any help would be much appreciated..

            I have noticed that when I choose different qmake, MySQL plugin is configured and prepared for building. Please have a look:

            embsys@JT-UBUNTU:~/raspi/test$ /home/embsys/Qt5.14.2/5.14.2/gcc_64/bin/qmake /home/embsys/raspi/qt-everywhere-src-5.12.3/qtbase/src/plugins/sqldrivers/sqldrivers.pro -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf
            
            Running configuration tests...
            Checking for DB2 (IBM)... no
            Checking for InterBase... no
            Checking for MySQL... yes
            Checking for OCI (Oracle)... no
            Checking for ODBC... no
            Checking for PostgreSQL... yes
            Checking for SQLite (version 2)... no
            Checking for TDS (Sybase)... no
            Done running configuration tests.
            
            Configure summary:
            
            Qt Sql Drivers:
              DB2 (IBM) .............................. no
              InterBase .............................. no
              MySql .................................. yes
              OCI (Oracle) ........................... no
              ODBC ................................... no
              PostgreSQL ............................. yes
              SQLite2 ................................ no
              SQLite ................................. yes
                Using system provided SQLite ......... no
              TDS (Sybase) ........................... no
            
            Qt is now configured for building. Just run 'make'.
            Once everything is built, you must run 'make install'.
            Qt will be installed into '/home/embsys/Qt5.14.2/5.14.2/gcc_64'.
            
            Prior to reconfiguration, make sure you remove any leftovers from
            the previous build.
            

            Unfortunately when I try to use the qmake for cross-compiler path I get the following:

            embsys@JT-UBUNTU:~/raspi/test$ /home/embsys/raspi/qtbase/qmake/qmake /home/embsys/raspi/qt-everywhere-src-5.12.3/qtbase/src/plugins/sqldrivers/sqldrivers.pro -- MYSQL_PREFIX=/home/embsys/raspi/sysroot/usr/lib/arm-linux-gnueabihf
            
            Running configuration tests...
            Checking for DB2 (IBM)... no
            Checking for InterBase... no
            Checking for MySQL... no
            Checking for OCI (Oracle)... no
            Checking for ODBC... yes
            Checking for PostgreSQL... yes
            Checking for SQLite (version 2)... yes
            Checking for TDS (Sybase)... yes
            Done running configuration tests.
            
            Configure summary:
            
            Qt Sql Drivers:
              DB2 (IBM) .............................. no
              InterBase .............................. no
              MySql .................................. no
              OCI (Oracle) ........................... no
              ODBC ................................... yes
              PostgreSQL ............................. yes
              SQLite2 ................................ yes
              SQLite ................................. yes
                Using system provided SQLite ......... no
              TDS (Sybase) ........................... yes
            
            Qt is now configured for building. Just run 'make'.
            Once everything is built, you must run 'make install'.
            Qt will be installed into '/home/embsys/raspi/qt5pi'.
            
            Prior to reconfiguration, make sure you remove any leftovers from
            the previous build.
            

            I lack good knowledge about qmake tool, but maybe there is something wrong with the qmake I try to use for Raspberry PI.
            BTW I have different qmakes in my host:

            embsys@JT-UBUNTU:~/raspi$ sudo find / -name qmake -type f
            /home/embsys/ti-processor-sdk-linux-rt-am335x-evm-05.03.00.07/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/qt5/qmake
            /home/embsys/ti-processor-sdk-linux-rt-am335x-evm-05.02.00.10/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/qt5/qmake
            /home/embsys/ti-processor-sdk-linux-am335x-evm-05.02.00.10/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/qt5/qmake
            /home/embsys/Qt5.14.2/qt-everywhere-src-5.14.2/qtbase/bin/qmake
            /home/embsys/Qt5.14.2/5.14.2/gcc_64/bin/qmake
            /home/embsys/raspi/qt5/bin/qmake
            /home/embsys/raspi/qtbase/bin/qmake
            /home/embsys/raspi/qtbase/qmake/qmake
            find: ‘/run/user/1000/doc’: Permission denied
            find: ‘/run/user/1000/gvfs’: Permission denied
            /usr/lib/x86_64-linux-gnu/qt4/bin/qmake
            /usr/lib/qt5/bin/qmake
            

            Could sb explain what is the difference between those qmakes that are in RPi paths? namely:

            /home/embsys/raspi/qt5/bin/qmake
            /home/embsys/raspi/qtbase/bin/qmake
            /home/embsys/raspi/qtbase/qmake/qmake
            

            I tried all of them but they give the same results.

            Is it possible that I somehow have a problem with Qt instalation for cross-compiling (and consequently with qmake) and this is the problem?

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JarekT
              wrote on 20 Jul 2020, 11:16 last edited by JarekT
              #26

              Finally (!...) I was able to fix the problems. I'm showing the whole procedure, not only what relates to the main subject of this thread so that to contribute to the community..

              I was using the following sites as a source information to work out the following solution: LINK1 (for other Qt/Raspberry PI configuration check: link), LINK2, LINK3, LINK4, LINK5, LINK6.

              My hardware/software:

              Host:
              Ubuntu 18.04 (also I’ve check it on Ubuntu 20.04 and it also works)
              Qt ver. 5.12.3 (I also tried 5.12.9, but it didn’t work, probably there was something wrong with the fix that needs to be done on the sources) - you can install the “sources” and all the modules you need from Qt Online Installer (link) because later on you can add/remove modules/versions easily by lauching ~/Qt/MaintenanceTool
              QtCreator will be installed automatically (the newest version) when you use Qt Online Installer

              Target:
              Raspberry PI 3, with Raspbian Stretch

              Procedure:

              1. [on RPi] Edit sources list in /etc/apt/sources.list and uncomment the deb-src line:
              sudo nano /etc/apt/sources.list
              
              1. [on RPi] Update your system and install required libraries:
              sudo apt-get update
              sudo apt-get build-dep qt4-x11
              sudo apt-get build-dep libqt5gui5
              sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
              

              After installing MySQL itself on RPi install also MySQL libraries/packages to be used by Qt:

              sudo apt install mariadb-client libmariadb-dev-compat libqt5sql5-mysql
              
              1. [on RPi] Prepare our target directory
              sudo mkdir /usr/local/qt5pi
              sudo chown pi:pi /usr/local/qt5pi
              
              1. [on RPi] Correct links to EGL and GLES Drivers
              sudo rm /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
              sudo rm /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
              sudo ln -s /opt/vc/lib/libbrcmEGL.so /usr/lib/arm-linux-gnueabihf/libEGL.so.1.0.0
              sudo ln -s /opt/vc/lib/libbrcmGLESv2.so /usr/lib/arm-linux-gnueabihf/libGLESv2.so.2.0.0
              
              1. [on host] Create our working directory and get a toolchain:
              mkdir ~/raspi
              cd ~/raspi
              git clone https://github.com/raspberrypi/tools
              
              1. [on host] Create a sysroot.
              mkdir sysroot sysroot/usr sysroot/opt
              rsync -avz pi@yourpi:/lib sysroot
              rsync -avz pi@yourpi:/usr/include sysroot/usr
              rsync -avz pi@yourpi:/usr/lib sysroot/usr
              rsync -avz pi@yourpi:/opt/vc sysroot/opt
              
              1. [on host] Adjust symlinks to be relative:
              wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
              chmod +x sysroot-relativelinks.py
              ./sysroot-relativelinks.py sysroot
              
              1. [on host] Modify the qmake.conf –> mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
              nano ~/raspi/qtbase/mkspecs/devices/linux-rasp-pi3-g++/qmake.conf
              

              VC_LIBRARY_PATH = $$[QT_SYSROOT]/opt/vc/lib
              VC_INCLUDE_PATH = $$[QT_SYSROOT]/opt/vc/include

              VC_LINK_LINE = -L$${VC_LIBRARY_PATH}

              QMAKE_LIBDIR_OPENGL_ES2 = $${VC_LIBRARY_PATH}
              QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
              QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2

              1. [on host] Protect your “sources” by creating working folder:
              cd ~/Qt/5.12.3
              tar jcvf qt-5.12.3-src.tar.bz2 Src
              cd ~/raspi
              tar xvf ~/Qt/5.12.3/qt-5.12.3-src.tar.bz2
              mv Src qt-5.12.3-src
              

              You can remove from qt-5.12.3-src the modules that you don’t want (at least for now) leaving qtbase folder - this will shorten the building process.
              Create also working folder for the building (if building would be unsuccessful all you need to do is to delete the content of this folder and start again):

              mkdir ~/raspi/build_raspi
              cd ~/raspi/build_raspi
              
              1. [on host] Configure
                From ~/raspi/build_raspi
              ../qt-5.12.3-src/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 -sql-mysql MYSQL_INCDIR=~/raspi/sysroot/usr/include/mysql MYSQL_LIBDIR=~/raspi/sysroot/usr/lib/arm-linux-gnueabihf
              

              Notice the above contains also building MySQL driver.

              Notice that the Config summary should contain (if it doesn't, you need to correct something... and do the configure again):
              EGLFS Raspberry Pi ................... yes
              MySql .................................. yes

              Regarding “-release” parameter read here (in other words you don’t need “-debug-and-release” and the warnings you can ignore… at least this is what I can read at the forum).

              1. [on host] Make
                From ~/raspi/build_raspi
              make
              

              You can use make -j 8 instead (much faster), but if there will be problems the all the “jobs” would need to finish and consequently it could be more difficult to find the error messages.

              1. [on host] Make install
                From ~/raspi/build_raspi:
              make install
              
              1. [on host] Deploy Qt to the device. We simply sync everything from ~/raspi/qt5pi to the prefix we configured above
                From ~/raspi:
              rsync -avz qt5pi pi@192.168.1.100:/usr/local
              
              1. [on host] Configuration of QtCreator:
              • Tools > Options > Devices > Add > Generic Linux Device > Start Wizard
              • Write: “Raspberry” (your custom name), “192.168.X.X” (your Raspberry PI address), “pi” (your Raspberry PI user)
              • Don’t write anything at “private key”, click “Next”
              • There will be error window with: “Device test failed” > Cancel
              • Authentication type → choose: “Default”
              • Now test connection (“Test” button) and after you give the password to the RPi it should be successful
              • Kits > Compilers > Add > GCC > C
              • Write: “GCC (Raspberry Pi)” as your custom name and: “~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc” as the path to the compiler
              • Kits > Compilers > Add > GCC > C++
              • Write: “G++ (Raspberry Pi)” as your custom name and: “~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++” as your path to the compiler
              • Regarding the debugger, you should install:
                [On Host]:
              sudo apt-get install gdb-multiarch
              

              I’m not sure if this is needed but you can also install on RPi:

              sudo apt-get install gdbserver
              
              • Kits > Debuggers > Add
              • Write: “GDB (Raspberry Pi)” as your custom name and “/usr/bin/gdb-multiarch” as the path to the debugger
              • Apply
              • Kits > Qt Version > Add
              • Write path: ~/raspi/qt5/bin/qmake
              • Write name: Qt %{Qt:Version} (qt5) Raspberry PI
              • Apply
              • Kits > Kits > Add
              • Name: Raspi
              • Device Type: Generic Linux Device
              • The Device is the one created in the previous step
              • We set the Sysroot to where we have the sysroot image: ~/raspi/sysroot
              • Set compilers: "GCC (Raspberry PI)" and "G++ (Raspberry PI)"
              • Set the Debugger to the one created previously
              • Use the Qt version we created previously
              • We don't need to set mkspec, so leave it empty.
              • OK
              • To enable your running application to have regular window do the following:
                Projects > Raspberry PI > Run > Environment > Batch Edit:
              DISPLAY=:0.0
              QT_QPA_PLATFORMTHEME=qt5ct
              XAUTHORITY=/home/pi/.Xauthority
              XDG_SESSION_TYPE=x11
              

              If you don’t do this your application after starting up will be shown full screen but you will see it only when directly connect a screen to Raspberry PI (VNC desktop sharing will show nothing)
              14) [on host] In your Raspberry PI project, in .pro file, you need to show where the executable file should be placed: (LINK):

              target.path = /home/pi
              INSTALLS += target
              

              So comment the previous settings, eg.:

              # qnx: target.path = /tmp/$${TARGET}/bin
              # else: unix:!android: target.path = /opt/$${TARGET}/bin
              # !isEmpty(target.path): INSTALLS += target
              
              1. [on host] If you get: “WARNING: The code model could not parse a included file, which might lead to incorrect code completion and highlighting”:
                You need to deselect “ClangCodeModel” in HELP > ABOUT PLUGINS and restart QtCreator (LINK).
              2. You should be able to build/run/debug your project on RPi and connect to the MySQL database without "QMYSQL driver not loaded" error.
              1 Reply Last reply
              1

              • Login

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