Qt C++ Android Remote MySQL
-
@Ryan-R said in Qt C++ Android Remote MySQL:
libmysql.lib, libmysql.dll & mysql.h
Those should be in lib and include subdirectories.
-
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).
-
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.
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. -
@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!
Ryan