Important: Please read the Qt Code of Conduct -

Qt C++ Android Remote MySQL

  • Hello guys,

    I have been developing an Android app for a commercial project using Qt C++ with a QML interface.

    I have been trying to get a remote connection to my Maria DB on a dedicated server. However, I'm having issues with the MySQL driver software; it seems that my computer does not have the required libraries. When I deploy for Windows, the MySQL library is available, but not loaded. And when I deploy for Android, it simply isn't there at all.

    W QSqlDatabase: QMYSQL driver not loaded
    W QSqlDatabase: available drivers: QSQLITE

    Although I have been following tutorials, I either get errors when I make, or the files do not get generated. I have placed the DLLs in the same place as the project executable with no luck.

    • "libmysql.dll", "qsqlmysqld.dll" and "qsqlmysql.dll" to program executable locations.
    • "sql" added to Qt+= pro configuration.
    • Gradle is configured for Android.

    Qt Creator 4.11.0, based on Qt 5.14.0 (MSVC 2017 32 bit, from rev 017ed74400) on Windows 10 64-bit, deploying to a Note 7P on Android version 9, compiling with Android for arm64-v8a (Clang Qt 5.12.5 for Android ARM64-v8a).

    Different people are saying to download different versions of the C connectors and SQL servers; do I download 64-bit, or do I need 32-bit for Android devices? Are there any more up-to-date tutorials or pre-compiled versions of Qt?

    I have uninstalled all versions of MySQL and connector software, as I had around 10 different versions from trying to get this to work!

    Any help would be appreciated.


  • Lifetime Qt Champion

    @Ryan-R said in Qt C++ Android Remote MySQL:

    "libmysql.dll", "qsqlmysqld.dll" and "qsqlmysql.dll" to program executable locations.

    Why? Please read the documentation: and

  • Hello,

    Thanks for the reply! I have followed the tutorial you posted for building the SQL Drivers; I have installed mysql-installer-web-community-; custom install. However, there is only the option for C++, not C as stated in the tutorial. So I went ahead and installed the C++ version just in case, browsed to "C:\Program Files (x86)\MySQL\Connector C++ 8.0" and the DLLs (libmysql.lib, libmysql.dll & mysql.h) are not present.

    I'm not sure if I'm missing something obvious!


  • Lifetime Qt Champion

    @Ryan-R said in Qt C++ Android Remote MySQL:

    libmysql.lib, libmysql.dll & mysql.h

    Those should be in lib and include subdirectories.

  • @Christian-Ehrlicher @jsulm

    Thanks for the reply! They're not in the sub-directories either.

    I still find it strange that the tutorial is asking for a C connector, but the only download they provide is for C++ (even though my app is coded in C++/QML).





  • Lifetime Qt Champion

    @Ryan-R Try to install Connector/C (at the bottom) and use that one. I'm not an expert here, but it can be that the MySQL Qt plug-in is using C API, not C++.

  • @jsulm

    Oh, that's embarrassing! I didn't see that one.

  • Lifetime Qt Champion

    @Ryan-R Yeah, it is strange why they prefix that one with "MySQL" but not the others.

  • Ok, so I've got it installed; all of the files are present. Now when I try to run qmake with the following command:

    C:\Qt\5.12.5\src\qtbase\src\plugins\sqldrivers> C:\Qt\5.12.5\android_arm64_v8a\bin\qmake -- MYSQL_INCDIR="C:/Program Files (x86)/MySQL/MySQLConnector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"

    I get the following error message:

    C:\Qt\5.12.5\src\qtbase\src\plugins\sqldrivers> C:\Qt\5.12.5\android_arm64_v8a\bin\qmake
    Project ERROR: You need to set the ANDROID_NDK_ROOT environment variable to point to your Android NDK.
    Could not read qmake configuration file C:/Qt/5.12.5/android_arm64_v8a/mkspecs/android-clang/qmake.conf.
    Error processing project file: C:\Qt\5.12.5\src\qtbase\src\plugins\sqldrivers\

    I edit the file qmake.conf. However, I can't seem to find any variables named "ANDROID_NDK_ROOT". Do I need to add this as a new line to the configuration file?

    # qmake configuration for building with android-clang
    QMAKE_PLATFORM          = android
    QMAKE_COMPILER          = gcc clang llvm
    CONFIG                 += android_install unversioned_soname unversioned_libname plugin_with_soname android_deployment_settings
    NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST
    QMAKE_CC      = $$NDK_LLVM_PATH/bin/clang
    QMAKE_CXX     = $$NDK_LLVM_PATH/bin/clang++
    equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
        QMAKE_CFLAGS += -target armv7-none-linux-androideabi
    else: equals(ANDROID_TARGET_ARCH, armeabi): \
        QMAKE_CFLAGS += -target armv5te-none-linux-androideabi
    else: equals(ANDROID_TARGET_ARCH, arm64-v8a): \
        QMAKE_CFLAGS += -target aarch64-none-linux-android
    else: equals(ANDROID_TARGET_ARCH, x86): \
        QMAKE_CFLAGS += -target i686-none-linux-android -mstackrealign
    else: equals(ANDROID_TARGET_ARCH, x86_64): \
        QMAKE_CFLAGS += -target x86_64-none-linux-android
    else: equals(ANDROID_TARGET_ARCH, mips): \
        QMAKE_CFLAGS += -target mipsel-none-linux-android
    else: equals(ANDROID_TARGET_ARCH, mips64): \
        QMAKE_CFLAGS += -target mips64el-none-linux-android
    QMAKE_CFLAGS += -gcc-toolchain $$NDK_TOOLCHAIN_PATH -fno-limit-debug-info
    QMAKE_LINK    = $$QMAKE_CXX $$QMAKE_CFLAGS -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -nostdlib++
    equals(ANDROID_TARGET_ARCH, armeabi-v7a): QMAKE_LINK += -Wl,--exclude-libs,libunwind.a
    QMAKE_CFLAGS += -DANDROID_HAS_WSTRING --sysroot=$$NDK_ROOT/sysroot \
                    -isystem $$NDK_ROOT/sysroot/usr/include/$$NDK_TOOLS_PREFIX \
                    -isystem $$NDK_ROOT/sources/cxx-stl/llvm-libc++/include \
                    -isystem $$NDK_ROOT/sources/android/support/include \
                    -isystem $$NDK_ROOT/sources/cxx-stl/llvm-libc++abi/include
    ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$$ANDROID_TARGET_ARCH
        ANDROID_CXX_STL_LIBS = -lc++
    else: \

    I do have qmake configured for the Qt Creator IDE, but I've never had to use the command-line to compile my projects, as it's all done through the IDE. I can confirm both qmake.conf and are both present in their respective locations.


    Thanks for the help!

  • Lifetime Qt Champion

    @Ryan-R Just now realised that you're building for Android. In that case the MySQL libs you installed will not help as those are for x86_64 Windows not Android. You will need either find precompiled MySQL libs for Android or build them manually.

  • Any chance you know how to manually build them, or know where to download them for this Android version? I have tried building them before, but was swarmed by errors from following the tutorials.

    I really don't want to have to use Xamarin for this app! I've been reading that it might be possible to use JavaScript with QML to execute some type of HTTP request that handles the data instead, and then get the server to run the query with localhost using PHP, instead of the app running the query directly.

    I made a back-end website to this app coded in HTML/CSS/PHP/JavaScript/MySQL, but I have only used TCP, UDP and SQL for transferring data between servers/clients.

    Some people reccommend XmlHttpRequest or Firebase, but have never used these protocols and wouldn't know where to start, or what the security implications are!

    Thanks for the help,

  • Lifetime Qt Champion

    @Ryan-R said in Qt C++ Android Remote MySQL:

    Any chance you know how to manually build them, or know where to download them for this Android version?

    No, sorry.

    "I made a back-end website to this app coded in HTML/CSS/PHP/JavaScript/MySQL" - then why do you need MySQL client stuff on Android? This sounds unusual. A mobile app should not connect directly to an exposed(!) SQL server, but use some API (like REST API) to communicate with the back-end server.

  • Well it's an analytics portal for displaying information such as user accounts, sales, as as well to configure some parts of the app and embedded machines remotely. We have SSL, I thought that as long as the traffic is encrypted, we have brute-force penetration protection and don't use the root login, there shouldn't any security issues as long as it's configured correctly?

    I'll have to start looking at APIs such as REST, are there any additional steps to configure these APIs with Qt, or do they work out-of-the-box with QML?

    Thanks for the information!

Log in to reply