Solved Qt C++ Android Remote MySQL
Thanks for the reply! I have followed the tutorial you posted for building the SQL Drivers; I have installed mysql-installer-web-community-126.96.36.199.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!
@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++.
Oh, that's embarrassing! I didn't see that one.
@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\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.
Thanks for the help!
@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.
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,
Any chance you know how to manually build them, or know where to download them for this Android version?
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!