Qt5.2 + Android + MySQL / PostgreSQL
-
MariaDB and MySQL are compatible; I used MariaDB because is what was being used on the tutorial I followed (I didn't make it), but I'm using it to connect both to MySQL and MariaDB servers. However indeed you only need one client library, either MySQL or MariaDB.
-
sorry for this RAzZziel, but dont load, stay longer for 2 months, its possible send to me your script
projetoslinux@gmail.comthanks
[quote author="RazZziel" date="1395676332"]Updated version for Qt 5.2.1: http://pastebin.com/k1u6gNe2[/quote]
-
This one shouldn't expire: http://pastebin.com/2A3EZQKA
Nor this one: https://gist.github.com/RazZziel/fd607459c1f07a43cdf9 -
Thank you very much RazZziel !!!!
-
Hi
[quote author="RazZziel" date="1400018116"]This one shouldn't expire: http://pastebin.com/2A3EZQKA
Nor this one: https://gist.github.com/RazZziel/fd607459c1f07a43cdf9[/quote]this compile Ok but in running mode
W/Qt ( 6583): kernel/qsqldatabase.cpp:785 (void QSqlDatabasePrivate::init(const QString&)): QSqlDatabase: QMYSQL driver not loaded
W/Qt ( 6583): kernel/qsqldatabase.cpp:786 (void QSqlDatabasePrivate::init(const QString&)): QSqlDatabase: available drivers: QSQLITE
D/Qt ( 6583): ../POSlinux/src/hal/maintablehal2.cpp:10396 (int MainTablehal2::ServerConexionM(int)): Conexxion ext Errornot load
how i can load this plugin, in linux my program work normally
but in Android not load after use your EXCELLENT !!!! scriptwhy i'm doing wrong ?????
-
I created a wiki post on how to build and use postgresql plugin
http://qt-project.org/wiki/Build_Qt5_postgresql_plugin_for_AndroidHere are the resulting libraries
https://drive.google.com/folderview?id=0ByPpOAN5EsHKfmgwRTFvQUl5Z1NvUnlYMHptTEs0d2xEc24xZ19Jb0ZDMTBpb3JDQ014ZkU -
I created a wiki post on how to build and use postgresql plugin
http://qt-project.org/wiki/Build_Qt5_postgresql_plugin_for_AndroidHere are the resulting libraries
https://drive.google.com/folderview?id=0ByPpOAN5EsHKfmgwRTFvQUl5Z1NvUnlYMHptTEs0d2xEc24xZ19Jb0ZDMTBpb3JDQ014ZkU -
@RazZziel said:
This one shouldn't expire: http://pastebin.com/2A3EZQKA
Nor this one: https://gist.github.com/RazZziel/fd607459c1f07a43cdf9After moving to qt.io the above patch doesn't work fine so I modified the new one a little bit everything went fine but when the patch arrived to Qt mysql pluing it failed because of the following error:
/home/hpctech-work/.Qt/android-ndk-r10e//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -O2 -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mthumb -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -Wno-psabi -W -fPIC -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_DEBUG -DQT_PLUGIN -DQT_SQL_LIB -DQT_CORE_LIB -I. -isystem /home/hpctech-work/.Qt/android-ndk-r10e/platforms/android-9/arch-arm/usr/include/mariadb -I/home/hpctech-work/.Qt/5.5/android_armv7/include -I/home/hpctech-work/.Qt/5.5/android_armv7/include/QtSql -I/home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore -I. -isystem /home/hpctech-work/.Qt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/include -isystem /home/hpctech-work/.Qt/android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -isystem /home/hpctech-work/.Qt/android-ndk-r10e/platforms/android-9/arch-arm/usr/include -I/home/hpctech-work/.Qt/5.5/android_armv7/mkspecs/android-g++ -o main.o main.cpp In file included from /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qnamespace.h:37:0, from /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qobjectdefs.h:41, from /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qobject.h:40, from /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qplugin.h:37, from /home/hpctech-work/.Qt/5.5/android_armv7/include/QtSql/qsqldriverplugin.h:37, from main.cpp:42: /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qglobal.h:693:47: error: expected constructor, destructor, or type conversion before 'static_assert' #define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message) ^ /home/hpctech-work/.Qt/5.5/android_armv7/include/QtCore/qplugin.h:136:5: note: in expansion of macro 'Q_STATIC_ASSERT_X' Q_STATIC_ASSERT_X(false, "Old plugin system used") ^ main.cpp:80:1: note: in expansion of macro 'Q_EXPORT_PLUGIN2' Q_EXPORT_PLUGIN2(qsqlmysql, QMYSQLDriverPlugin) ^ make: *** [main.o] Error 1 Changes: diff: ./rootfs_files_before.txt: No such file or directory hpctech-work@hpctech-work ~/HPCTECH/Projects/MysqlClient/build-libmysql-android $
How can I fix this issue?
The full modified patch file is:
#!/bin/bash # Based on http://qt-project.org/wiki/Build_Qt5_mysql_plugin_for_Android export ANDROID_NDK_ROOT="$HOME/.Qt/android-ndk-r10e/" export QT_ROOT="$HOME/.Qt/5.5/" SR="$ANDROID_NDK_ROOT/platforms/android-9/arch-arm/" BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-" here="$(dirname "$0")" find "$SR" > "$here/rootfs_files_before.txt" || exit 1 checkChanges() { find "$SR" > "$here/rootfs_files_after.txt" || exit 1 echo "Changes:" diff -u "$here/rootfs_files_before.txt" "$here/rootfs_files_after.txt" } trap checkChanges EXIT # OpenSSL #pkg=openssl-1.0.1f.tar.gz #pkg=openssl-1.0.1e.tar.gz pkg=openssl-1.0.2d.tar.gz dir=$(basename $pkg .tar.gz) if [ ! -d $dir ]; then wget -c http://www.openssl.org/source/$pkg tar -xf $pkg || exit 1 fi pushd $dir RANLIB="$BR"ranlib CC="$BR"gcc ./Configure android-armv7 --prefix=$SR/usr ANDROID_DEV=$SR/usr make #|| exit 1 ANDROID_DEV=$SR/usr make || exit 1 make install_sw || exit 1 popd # libiconv pkg=libiconv-1.14.tar.gz dir=$(basename $pkg .tar.gz) if [ ! -d $dir ]; then wget -c http://ftp.gnu.org/pub/gnu/libiconv/$pkg tar -xf $pkg || exit 1 fi pushd $dir STRIP="$BR"strip RANLIB="$BR"ranlib OBJDUMP="$BR"objdump AR="$BR"ar CC="$BR"gcc CFLAGS=--sysroot=$SR CPP="$BR"cpp CPPFLAGS=$CFLAGS ./configure --host=arm --prefix=$SR/usr --with-sysroot=$SR make || exit 1 make install || exit 1 popd # mariadbclient version=2.0.0 pkg=mariadb_client-$version-src.tar.gz url=https://downloads.mariadb.org/f/client-native-$version/src/$pkg # FIXME: This one fails to build, linker errors #version=2.1.0 #pkg=mariadb-connector-c-$version-src.tar.gz #url=https://downloads.mariadb.org/f/connector-c-$version/source-tgz/$pkg dir=$(basename $pkg .tar.gz) if [ ! -d $dir ]; then wget -c $url tar -xf $pkg || exit 1 fi pushd $dir sed -i -e "s|ADD_SUBDIRECTORY(unittest/libmariadb)|#ADD_SUBDIRECTORY(unittest/libmariadb)|" CMakeLists.txt sed -i -e "N; s|typedef unsigned short ushort;\n#endif|#endif\ntypedef unsigned short ushort;|" include/my_global.h sed -i -e "N; s|SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION.*||" libmariadb/CMakeLists.txt sed -i -e "N; s|SOVERSION \${CPACK_PACKAGE_VERSION_MAJOR})||" libmariadb/CMakeLists.txt # Pig disgusting: the previous multiline thingie should've done it sed -i -e "N; s|\${CPACK_PACKAGE_VERSION_MAJOR}||" libmariadb/CMakeLists.txt # Pig disgusting: what the fuck mkdir build pushd build PKG_CONFIG_PATH=$SR/usr/lib/pkgconfig cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_FLAGS=--sysroot="$SR" \ -DCMAKE_INSTALL_PREFIX="$SR/usr" \ -DCMAKE_C_COMPILER="$BR"gcc \ -DCMAKE_LINKER="$BR"ld \ -DCMAKE_AR="$BR"ar \ -DCMAKE_NM="$BR"nm \ -DCMAKE_OBJCOPY="$BR"objcopy \ -DCMAKE_OBJDUMP="$BR"objdump \ -DCMAKE_RANLIB="$BR"ranlib \ -DCMAKE_STRIP="$BR"strip \ -DICONV_INCLUDE_DIR="$SR/usr/include" \ -DICONV_LIBRARIES="$SR/usr/lib/libiconv.a" \ -DWITH_EXTERNAL_ZLIB=ON \ -DZLIB_INCLUDE_DIR="$SR/usr/include" \ -DZLIB_LIBRARY="$SR/usr/lib/libz.so" ../ || exit 1 make install || exit 1 popd # ??? pwd cp build/libmariadb/*.{a,so} "$SR/usr/lib/mariadb/" || exit 1 popd # qt qmake="$QT_ROOT/android_armv7/bin/qmake" [ ! -f "$qmake" ] && { echo "Could not find qmake in '$qmake'"; exit 1; } [ ! -x "$qmake" ] && { echo "Qmake is not executable in '$qmake'"; exit 1; } qtVersion=$(qmake -query QT_VERSION) pkg=qt-everywhere-opensource-src-$qtVersion.tar.gz #pkg=qtbase-opensource-src-$qtVersion.tar.gz dir=$(basename $pkg .tar.gz) if [ ! -d $dir ]; then # wget -c http://download.qt.io/official_releases/qt/${qtVersion%.*}/$qtVersion/submodules/$pkg wget -c http://download.qt.io/official_releases/qt/${qtVersion%.*}/$qtVersion/$pkg tar -xf $pkg || exit 1 fi pushd $dir/src/plugins/sqldrivers/mysql/ $qmake "INCLUDEPATH+=$SR/usr/include/mariadb" "LIBS+=$SR/usr/lib/mariadb/libmariadbclient.a $SR/usr/lib/libssl.a $SR/usr/lib/libcrypto.a $SR/usr/lib/libiconv.a" "LIBPATH+=$SR/usr/lib/mariadb" -o Makefile mysql.pro make || exit 1 make install || exit 1 popd echo echo "BOOYAH!!!" echo
-
I fixed this issue by using the following modifications
https://gist.github.com/hpctech/a16f94f7ac3524d49219#file-buildandroidmysql-sh -
Hi,
Many thanks for "buildAndroidMysql.sh" !
But i have a problem.
When :PKG_CONFIG_PATH=$SR/usr/lib/pkgconfig cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=--sysroot="$SR" -DCMAKE_INS TALL_PREFIX="$SR/usr" -DCMAKE_C_COMPILER="$BR"gcc -DCMAKE_LINKER="$BR"ld -DCMAKE_AR="$BR"ar -DCMAKE_NM="$BR"nm -DCMA KE_OBJCOPY="$BR"objcopy -DCMAKE_OBJDUMP="$BR"objdump -DCMAKE_RANLIB="$BR"ranlib -DCMAKE_STRIP="$BR"strip -DICONV_INC LUDE_DIR="$SR/usr/include" -DICONV_LIBRARIES="$SR/usr/lib/libiconv.a" -DWITH_EXTERNAL_ZLIB=ON -DZLIB_INCLUDE_DIR="$S R/usr/include" -DZLIB_LIBRARY="$SR/usr/lib/libz.so" ../
I have this error :
CMake Error at CMakeLists.txt:5 (PROJECT): CMAKE_SYSTEM_NAME is 'Android' but 'NVIDIA Nsight Tegra Visual Studio Edition' is not installed.
Build on Windows 10 x64 for Android.
MySQL Plugin for Qt 5.7.0.Many thanks for help.
-
@Yohan07 Do you success on building mysql driver for android on windows?
I want to build it also by qt5.11.0 ,but can't get it?