1

I try to build the MySQL plugin on a Raspbian Buster with C++ and Qt 5.12.4. Building Qt itself worked fine by following this tutorial: https://www.tal.org/tutorials/building-qt-512-raspberry-pi

However, if I add the option -sql-mysql to the command

PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig ../qt-everywhere-src-5.12.4/configure -platform linux-rpi-g++ -v -opengl es2 -eglfs -no-gtk -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -no-feature-geoservices_mapboxgl -qt-pcre -no-pch -ssl -evdev -system-freetype -fontconfig -glib -prefix /opt/Qt5.12 -qpa eglfs -sql-mysql

the output results in the following error:

ERROR: Feature 'sql-mysql' was enabled, but the pre-condition 'libs.mysql' failed.

I assume that this is due to that the MySQL libraries were exchanged by MariaDB libraries in Raspbian Buster. Does anybody know, how to build Qt's MySql driver using the MariaDB libraries or in worst case how to install the MySQL libraries on Raspbian Buster?

3 Answers 3

1

You need to install the Mariadb packages and the mysql compatibility package in your sysroot.

apt install mariadb-client mariadb-common mysql-common libmariadb-dev-compat libmariadbclient-dev

libmariadb-dev-compat package will create all the links necessary for compatibility between mariadb and mysql. Then, when you call to qt configure script you must indicate the path of the mysql (mariadb) libraries:

-sql-mysql MYSQL_INCDIR=/opt/rpi/buster_enigma/sysroot/usr/include/mysql MYSQL_LIBDIR=/opt/rpi/buster_enigma/sysroot/usr/lib/arm-linux-gnueabihf

Tested on host Ubuntu 18.04 - Target Raspbian Buster - QT 5.12.5

2

I found a solution although this is not the straightforward way to compile all at once.

First I compiled and installed Qt 5.12.4 without the MySQL driver plugin as described in the tutorial referenced in my original question.

I'm not sure if this next step is really required, but then I created symbolic links to redirect from MySQL to MariaDB in order to assure that the qmake will find the expected MySQL libraries:

sudo ln -s /usr/lib/arm-linux-gnueabihf/libmariadbclient.a /usr/lib/arm-linux-gnueabihf/libmysqlclient.a
sudo ln -s /usr/lib/arm-linux-gnueabihf/libmysqlclient_r.a /usr/lib/arm-linux-gnueabihf/libmysqlclient_r.a
sudo ln -s /usr/lib/arm-linux-gnueabihf/libmysqlclient_r.so /usr/lib/arm-linux-gnueabihf/libmysqlclient_r.so
sudo ln -s /usr/lib/arm-linux-gnueabihf/libmysqlclient.so /usr/lib/arm-linux-gnueabihf/libmysqlclient.so

Thereafter I followed the official Qt documentation on "How to Build the QMYSQL Plugin on Unix and macOS" (https://doc.qt.io/qt-5/sql-driver.html):

Thus I changed into the the source directory:

cd qt-everywhere-src-5.12.4/qtbase/src/plugins/sqldrivers/

I executed the previously installed qmake and provided the path to my symbolic links

/opt/Qt5.12/bin/qmake -- MYSQL_PREFIX=/usr/lib/arm-linux-gnueabihf

which yields

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 '/opt/Qt5.12'.

Prior to reconfiguration, make sure you remove any leftovers from
the previous build.

Then I build the MySQL driver plugin

make sub-mysql

which was found in

qt-everywhere-src-5.12.4/qtbase/src/plugins/sqldrivers/mysql

Finally, I simply copied the built library into the related location of my Qt 5.12 installation:

sudo cp plugins/sqldrivers/libqsqlmysql.so /opt/Qt5.12/plugins/sqldrivers/

This approach is maybe not the perfect solution, but at least it worked for me.

1

On my build ouput MySQL did work according to my output ( but can't test as i get errors regarding OpenGl when i start my compiled application ) I compiled on on a 4GB Pi4 with the Raspbian Buster Lite . Does EGLFS work for you ?

I did install these libs maybe this will fix it for you ? :

sudo apt-get install sense-hat libatspi-dev build-essential libfontconfig1-dev libdbus-1-dev libfreetype6-dev libicu-dev libinput-dev libxkbcommon-dev libsqlite3-dev libssl-dev libpng-dev libjpeg-dev libglib2.0-dev libraspberrypi-dev
sudo apt-get install bluez libbluetooth-dev
sudo apt-get install libasound2-dev pulseaudio libpulse-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-alsa gstreamer-tools
sudo apt-get install libpq-dev libmariadbclient-dev

My configuration was like this :

PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig PKG_CONFIG_SYSROOT_DIR=/ \../qt-everywhere-src-5.12.4/configure -v -opengl es2 -eglfs -no-xcb -no-pch -no-gtk -device linux-rasp-pi3-g++ \-device-option CROSS_COMPILE=/usr/bin/ -opensource -confirm-license -reduce-exports \-force-pkg-config -nomake examples -no-compile-examples -skip qtwayland -skip qtwebengine -release \-qt-pcre -ssl -evdev -system-freetype -fontconfig -glib -gstreamer -prefix /opt/QT5

This was the output of my configuration

    Configure summary:

    Building on: linux-g++ (arm, CPU features: <none>)
    Building for: devices/linux-rasp-pi3-g++ (arm, CPU features: neon)
    Target compiler: gcc 8.3.0
    Configuration: cross_compile use_gold_linker enable_new_dtags largefile neon shared rpath release c++11 c++14 c++1z concurrent dbus reduce_exports stl
    Build options:
      Mode ................................... release
      Optimize release build for size ........ no
      Building shared libraries .............. yes
      Using C standard ....................... C11
      Using C++ standard ..................... C++1z
      Using ccache ........................... no
      Using gold linker ...................... yes
      Using new DTAGS ........................ yes
      Using precompiled headers .............. no
      Using LTCG ............................. no
      Target compiler supports:
        NEON ................................. yes
      Build parts ............................ libs
    Qt modules and options:
      Qt Concurrent .......................... yes
      Qt D-Bus ............................... yes
      Qt D-Bus directly linked to libdbus .... yes
      Qt Gui ................................. yes
      Qt Network ............................. yes
      Qt Sql ................................. yes
      Qt Testlib ............................. yes
      Qt Widgets ............................. yes
      Qt Xml ................................. yes
    Support enabled for:
      Using pkg-config ....................... yes
      udev ................................... yes
      Using system zlib ...................... yes
    Qt Core:
      DoubleConversion ....................... yes
        Using system DoubleConversion ........ yes
      GLib ................................... yes
      iconv .................................. no
      ICU .................................... yes
      Tracing backend ........................ <none>
      Logging backends:
        journald ............................. no
        syslog ............................... no
        slog2 ................................ no
      Using system PCRE2 ..................... no
    Qt Network:
      getifaddrs() ........................... yes
      IPv6 ifname ............................ yes
      libproxy ............................... no
      Linux AF_NETLINK ....................... yes
      OpenSSL ................................ yes
        Qt directly linked to OpenSSL ........ no
      OpenSSL 1.1 ............................ yes
      DTLS ................................... yes
      SCTP ................................... no
      Use system proxies ..................... yes
    Qt Gui:
      Accessibility .......................... yes
      FreeType ............................... yes
        Using system FreeType ................ yes
      HarfBuzz ............................... yes
        Using system HarfBuzz ................ yes
      Fontconfig ............................. yes
      Image formats:
        GIF .................................. yes
        ICO .................................. yes
        JPEG ................................. yes
          Using system libjpeg ............... yes
        PNG .................................. yes
          Using system libpng ................ yes
      EGL .................................... yes
      OpenVG ................................. no
      OpenGL:
        Desktop OpenGL ....................... no
        OpenGL ES 2.0 ........................ yes
        OpenGL ES 3.0 ........................ yes
        OpenGL ES 3.1 ........................ yes
        OpenGL ES 3.2 ........................ yes
      Vulkan ................................. yes
      Session Management ..................... yes
    Features used by QPA backends:
      evdev .................................. yes
      libinput ............................... yes
      INTEGRITY HID .......................... no
      mtdev .................................. yes
      tslib .................................. no
      xkbcommon .............................. yes
      X11 specific:
        XLib ................................. yes
        XCB Xlib ............................. yes
        EGL on X11 ........................... no
    QPA backends:
      DirectFB ............................... no
      EGLFS .................................. yes
      EGLFS details:
        EGLFS OpenWFD ........................ no
        EGLFS i.Mx6 .......................... no
        EGLFS i.Mx6 Wayland .................. no
        EGLFS RCAR ........................... no
        EGLFS EGLDevice ...................... no
        EGLFS GBM ............................ yes
        EGLFS VSP2 ........................... no
        EGLFS Mali ........................... no
        EGLFS Raspberry Pi ................... yes
        EGLFS X11 ............................ no
      LinuxFB ................................ yes
      VNC .................................... yes
      Mir client ............................. no
    Qt Sql:
      SQL item models ........................ yes
    Qt Widgets:
      GTK+ ................................... no
      Styles ................................. Fusion Windows
    Qt PrintSupport:
      CUPS ................................... yes
    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 Testlib:
      Tester for item models ................. yes
    Qt SerialBus:
      Socket CAN ............................. yes
      Socket CAN FD .......................... yes
    Further Image Formats:
      JasPer ................................. no
      MNG .................................... yes
      TIFF ................................... yes
        Using system libtiff ................. yes
      WEBP ................................... yes
        Using system libwebp ................. no
    Qt QML:
      QML network support .................... yes
      QML debugging and profiling support .... yes
      QML sequence object .................... yes
      QML list model ......................... yes
      QML XML http request ................... yes
      QML Locale ............................. yes
      QML delegate model ..................... yes
    Qt Quick:
      Direct3D 12 ............................ no
      AnimatedImage item ..................... yes
      Canvas item ............................ yes
      Support for Qt Quick Designer .......... yes
      Flipable item .......................... yes
      GridView item .......................... yes
      ListView item .......................... yes
      TableView item ......................... yes
      Path support ........................... yes
      PathView item .......................... yes
      Positioner items ....................... yes
      Repeater item .......................... yes
      ShaderEffect item ...................... yes
      Sprite item ............................ yes
    Qt Scxml:
      ECMAScript data model for QtScxml ...... yes
    Qt Gamepad:
      SDL2 ................................... no
    Qt 3D:
      Assimp ................................. yes
      System Assimp .......................... no
      Output Qt3D Job traces ................. no
      Output Qt3D GL traces .................. no
      Use SSE2 instructions .................. no
      Use AVX2 instructions .................. no
      Aspects:
        Render aspect ........................ yes
        Input aspect ......................... yes
        Logic aspect ......................... yes
        Animation aspect ..................... yes
        Extras aspect ........................ yes
    Qt 3D Renderers:
      OpenGL Renderer ........................ yes
    Qt 3D GeometryLoaders:
      Autodesk FBX ........................... no
    Qt Bluetooth:
      BlueZ .................................. yes
      BlueZ Low Energy ....................... yes
      Linux Crypto API ....................... yes
      WinRT Bluetooth API (desktop & UWP) .... no
    Qt Sensors:
      sensorfw ............................... no
    Qt Quick Controls 2:
      Styles ................................. Default Fusion Imagine Material Universal
    Qt Quick Templates 2:
      Hover support .......................... yes
      Multi-touch support .................... yes
    Qt Positioning:
      Gypsy GPS Daemon ....................... no
      WinRT Geolocation API .................. no
    Qt Location:
      Qt.labs.location experimental QML plugin . yes
      Geoservice plugins:
        OpenStreetMap ........................ yes
        HERE ................................. yes
        Esri ................................. yes
        Mapbox ............................... yes
        MapboxGL ............................. yes
        Itemsoverlay ......................... yes
    QtXmlPatterns:
      XML schema support ..................... yes
    Qt Multimedia:
      ALSA ................................... yes
      GStreamer 1.0 .......................... yes
      GStreamer 0.10 ......................... no
      Video for Linux ........................ yes
      OpenAL ................................. no
      PulseAudio ............................. yes
      Resource Policy (libresourceqt5) ....... no
      Windows Audio Services ................. no
      DirectShow ............................. no
      Windows Media Foundation ............... no
    Qt Tools:
      QDoc ................................... no

    Note: Also available for Linux: linux-clang linux-icc

    WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.

    Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.
    On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
    On macOS, you can use Homebrew's llvm package.
    On Windows, you must set LLVM_INSTALL_DIR to the installation path.

    Qt is now configured for building. Just run 'make'.
    Once everything is built, you must run 'make install'.
    Qt will be installed into '/opt/QT5'.

    Prior to reconfiguration, make sure you remove any leftovers from
    the previous build.
5
  • Thank you for the reply. Why do you think that in your case MySQL is working? I found only the line "MySql .................................. no", which lets me assume that it will not work. And yes, EGLFS works for me. I guess you need to install at least glib2 (and maybe further libraries) sudo apt-get install libglib2.0-dev
    – elnacho
    Jul 5, 2019 at 7:34
  • Sorry you are right i only saw that now i only looked into the line Qt Sql ................................. yes and not into the MySql . and i funny enough didn't get the same errors as you . Are you on pi3 or pi4 ? Jul 5, 2019 at 10:45
  • I utilise a pi3b+.
    – elnacho
    Jul 5, 2019 at 12:43
  • Hi, author of the referenced site here. Try running Qt configure with verbose option and log the output. You should be able to find out from the verbose output what fails in the mysql/mariadb library check.
    – onion
    Jul 11, 2019 at 8:33
  • Thank you onion, I guess this hint brought me closer to the below given solution.
    – elnacho
    Aug 6, 2019 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.