Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt C++ Android Remote MySQL
Forum Update on Monday, May 27th 2025

Qt C++ Android Remote MySQL

Scheduled Pinned Locked Moved Solved Mobile and Embedded
13 Posts 3 Posters 2.3k 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.
  • R Ryan R
    29 Jan 2020, 09:21

    Hello,

    Thanks for the reply! I have followed the tutorial you posted for building the SQL Drivers; I have installed mysql-installer-web-community-8.0.18.0.msi; 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!

    Thanks,
    Ryan

    J Offline
    J Offline
    jsulm
    Lifetime Qt Champion
    wrote on 29 Jan 2020, 09:24 last edited by
    #4

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

    libmysql.lib, libmysql.dll & mysql.h

    Those should be in lib and include subdirectories.

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

    1 Reply Last reply
    1
    • R Offline
      R Offline
      Ryan R
      wrote on 29 Jan 2020, 09:32 last edited by Ryan R
      #5

      @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).

      ce938be8-ce1f-431e-aaaa-724f8d1ac4c7-image.png

      40e8c42b-7ecd-4639-8638-05b6e8644eb7-image.png

      edcc1934-0fc1-4798-9b17-87e8142b2f4c-image.png

      6fa8f79e-355a-4197-99cc-b9ad2a88370f-image.png

      J 1 Reply Last reply 29 Jan 2020, 09:52
      0
      • R Ryan R
        29 Jan 2020, 09:32

        @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).

        ce938be8-ce1f-431e-aaaa-724f8d1ac4c7-image.png

        40e8c42b-7ecd-4639-8638-05b6e8644eb7-image.png

        edcc1934-0fc1-4798-9b17-87e8142b2f4c-image.png

        6fa8f79e-355a-4197-99cc-b9ad2a88370f-image.png

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 29 Jan 2020, 09:52 last edited by
        #6

        @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++.

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

        R 1 Reply Last reply 29 Jan 2020, 09:54
        1
        • J jsulm
          29 Jan 2020, 09:52

          @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++.

          R Offline
          R Offline
          Ryan R
          wrote on 29 Jan 2020, 09:54 last edited by
          #7

          @jsulm

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

          J 1 Reply Last reply 29 Jan 2020, 09:56
          0
          • R Ryan R
            29 Jan 2020, 09:54

            @jsulm

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

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 29 Jan 2020, 09:56 last edited by
            #8

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

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

            1 Reply Last reply
            1
            • R Offline
              R Offline
              Ryan R
              wrote on 29 Jan 2020, 10:17 last edited by Ryan R
              #9

              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\sqldrivers.pro
              

              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
              MAKEFILE_GENERATOR      = UNIX
              QMAKE_PLATFORM          = android
              QMAKE_COMPILER          = gcc clang llvm
              
              CONFIG                 += android_install unversioned_soname unversioned_libname plugin_with_soname android_deployment_settings
              
              include(../common/linux.conf)
              include(../common/gcc-base-unix.conf)
              include(../common/clang.conf)
              include(../common/android-base-head.conf)
              
              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_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++_shared.so
              
              ANDROID_USE_LLVM = true
              
              exists($$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so): \
                  ANDROID_CXX_STL_LIBS = -lc++
              else: \
                  ANDROID_CXX_STL_LIBS = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so.$$replace(ANDROID_PLATFORM, "android-", "")
              
              QMAKE_CFLAGS_OPTIMIZE_SIZE = -Oz
              
              include(../common/android-base-tail.conf)
              
              

              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 sqldrivers.pro are both present in their respective locations.

              584641ea-3a3d-4a4d-b0aa-efcf771f5efe-image.png

              Thanks for the help!

              J 1 Reply Last reply 29 Jan 2020, 11:52
              0
              • R Ryan R
                29 Jan 2020, 10:17

                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\sqldrivers.pro
                

                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
                MAKEFILE_GENERATOR      = UNIX
                QMAKE_PLATFORM          = android
                QMAKE_COMPILER          = gcc clang llvm
                
                CONFIG                 += android_install unversioned_soname unversioned_libname plugin_with_soname android_deployment_settings
                
                include(../common/linux.conf)
                include(../common/gcc-base-unix.conf)
                include(../common/clang.conf)
                include(../common/android-base-head.conf)
                
                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_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++_shared.so
                
                ANDROID_USE_LLVM = true
                
                exists($$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so): \
                    ANDROID_CXX_STL_LIBS = -lc++
                else: \
                    ANDROID_CXX_STL_LIBS = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libc++.so.$$replace(ANDROID_PLATFORM, "android-", "")
                
                QMAKE_CFLAGS_OPTIMIZE_SIZE = -Oz
                
                include(../common/android-base-tail.conf)
                
                

                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 sqldrivers.pro are both present in their respective locations.

                584641ea-3a3d-4a4d-b0aa-efcf771f5efe-image.png

                Thanks for the help!

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 29 Jan 2020, 11:52 last edited by
                #10

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

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

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Ryan R
                  wrote on 29 Jan 2020, 12:10 last edited by
                  #11

                  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,
                  Ryan.

                  J 1 Reply Last reply 29 Jan 2020, 12:52
                  0
                  • R Ryan R
                    29 Jan 2020, 12:10

                    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,
                    Ryan.

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 29 Jan 2020, 12:52 last edited by
                    #12

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

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

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Ryan R
                      wrote on 29 Jan 2020, 14:02 last edited by Ryan R
                      #13

                      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!
                      Ryan

                      1 Reply Last reply
                      0

                      13/13

                      29 Jan 2020, 14:02

                      • Login

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