Unable to build MySQL plugin
-
- Linux Mint 17.3 x64 xfce
- Full shell script I used:
#!/bin/bash # Based on https://gist.github.com/RazZziel/fd607459c1f07a43cdf9 export ANDROID_NDK_ROOT="$HOME/.android/android-ndk-r12b/" export QT_ROOT="$HOME/.Qt/5.7/" SR="$ANDROID_NDK_ROOT/platforms/android-17/arch-arm/" BR="$ANDROID_NDK_ROOT/toolchains/arm-linux-androideabi-4.9/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.1e.tar.gz pkg=openssl-1.0.2h.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=http://archive.mariadb.org/client-native-$version/src/$pkg # FIXME: This one fails to build, linker errors #version=2.3.0 #pkg=mariadb-connector-c-$version-src.tar.gz #url=https://downloads.mariadb.org/f/connector-c-$version/$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) qtVersion=5.7.0 #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
-
Hmmm, weird, I actually have no idea what could've gone wrong.
Have you tried building Qt 5.5? I can't test 5.7 right now, but I've jut tried 5.5 and it works fine on my machine (Archlinux x86_64) with the unmodified latest version of the script in git@gist.github.com:/fd607459c1f07a43cdf9.git
EDIT: Invalid test; I didn't have an Android toolchain installed and nothing was actually being done because I hadn't cleared my cache. Can't test right now, sorry :( but please do try the unmodified script, and please inform us of your Linux distro and version
-
@loogicalrobo said in Unable to build MySQL plugin:
@mbnoimi.. i am suffering in same problem so would you have any idea how to solved that probelm
Unfortunately I didn't solve it so I created my app using Delphi XE instead of Qt... It seems that Qt gurus don't care much about database (this is general problem in Qt since years ago)
-
Hi,
There's is officially no native support for MySQL on Android. The fact that MariaDB can be built to be used on that platform is pure luck.
A better place to get more help with that library would be the MariaDB forums.
Also note that writing an application that requires direct database access also have security implications. Usually, on mobile platforms, REST services are used to interact with databases.
@mbnoimi This is a community driven forum, you can't expect the people answering here to have answers for all corner cases which MySQL on Android is one.
-
Hello everyone,
I'm developing cross platform application and i need mysql library for my app. So i successfully compiled it for android too :)
This is my Bitbucket link: MySQL_Driver_Qt
Just edit it for your NDK_ROOT, QT_ROOT and other parameters. Don't edit after "Don't edit after this line"
Call it with "sudo ./build_qt_mysql_driver.sh"
-
Thanks for sharing !
Out of curiosity, why
sudo
? -
thanks a lot for sharing, although I set the right variables but I get the following error:
mariadb compiled !!! Root privileges is needed for compiling and installing the driver !!! ~/.Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql ~/Desktop/mysql_driver_qt make: *** No rule to make target 'clean'. Stop. Project ERROR: Library 'mysql' is not defined. make: *** No targets specified and no makefile found. Stop. mbnoimi@mbnoimi-laptop ~/Desktop/mysql_driver_qt $
-
You are welcome.I updated my script. And i added two QT pro file. Please check my BitBucket repository. In Qt v5.8, there is some errors in mysql.pro file, so you can replace it by my pro file from repository. In the repository, there are two different pro file for android and linux version. Use android_mysql.pro and copy it to ./Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql folder and rename as "mysql.pro"
Maybe you can take backup of original mysql.pro before replacing by my file.Then just run my script.
You should run this script if your qt sources are under root folder. Mines are under /opt so i have to :) If yours are under /home folder, so you don't need to.
-
@aykutozdemir said in Unable to build MySQL plugin:
You are welcome.I updated my script. And i added two QT pro file. Please check my BitBucket repository. In Qt v5.8, there is some errors in mysql.pro file, so you can replace it by my pro file from repository. In the repository, there are two different pro file for android and linux version. Use android_mysql.pro and copy it to ./Qt/5.8/Src/qtbase/src/plugins/sqldrivers/mysql folder and rename as "mysql.pro"
Maybe you can take backup of original mysql.pro before replacing by my file.Then just run my script.
Thanks a lot, the script worked like a charm. You can modify it by add the following two lines:
# Fix Qt MySQL projects cp $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql_orig.pro cp android_mysql.pro $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro
-
@mbnoimi said in Unable to build MySQL plugin:
Fix Qt MySQL projects
cp $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.pro $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql_orig.pro
cp android_mysql.pro $QT_ROOT/Src/qtbase/src/plugins/sqldrivers/mysql/mysql.proThank you for this too, i'm adding these lines to the script.
-
@aykutozdemir
Hi.ty could not help me to create a MySql plugin for android in qt.You can not create a video instruction about this? If you can already create working compiled MySql plugins under different platforms from 17 and up to now 26? Thanks in advance! -
can i export this script to windows and use it there?