Building Qt 5.10.1 MySQL Plugin for Android
-
Hello,
i want to use the MySql functionality of Qt under Android. I found the tutorial on building the plugin in the Qt-Wiki and used this script to build it:#!/bin/bash # Based on http://qt-project.org/wiki/Build_Qt5_mysql_plugin_for_Android export ANDROID_NDK_ROOT="$HOME/android-ndk-r10e/" export QT_ROOT="$HOME/Qt/5.10.1/" SR="$ANDROID_NDK_ROOT/platforms/android-17/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 pkg=qtbase-everywhere-src-5.10.1.tar.xz dir=$(basename $pkg .tar.xz) 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 wget -c http://download.qt.io/official_releases/qt/5.10/5.10.1/submodules/qtbase-everywhere-src-5.10.1.tar.xz 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
It builds all fine until the last step where qmake should build the plugin. I get the error:
~/sqlplugin/mariadb_client-2.0.0-src ~/sqlplugin /home/mathis/sqlplugin/mariadb_client-2.0.0-src ~/sqlplugin qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory ~/sqlplugin/qtbase-everywhere-src-5.10.1/src/plugins/sqldrivers/mysql ~/sqlplugin Info: creating stash file /home/mathis/sqlplugin/qtbase-everywhere-src-5.10.1/src/plugins/sqldrivers/.qmake.stash Cannot read /home/mathis/sqlplugin/qtbase-everywhere-src-5.10.1/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory Project ERROR: Library 'mysql' is not defined. make: *** No targets specified and no makefile found. Stop. Changes: diff: ./rootfs_files_before.txt: No such file or directory
The error is right: The file "qtsqldrivers-config.pri" does not exists at that location.
I then tried to qmake the parent directory (sqldrivers):
$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 sqldrivers.pro
But it can't find the MySql dependencies:
Configure summary: Qt Sql: DB2 (IBM) .............................. no InterBase .............................. no MySql .................................. no OCI (Oracle) ........................... no ODBC ................................... no PostgreSQL ............................. no SQLite2 ................................ no SQLite ................................. yes Using system provided SQLite ......... no TDS (Sybase) ........................... no
What do i have to add to let qmake recognize my libmariadbclient correctly?
-
Hi
@PsAePr said in Building Qt 5.10.1 MySQL Plugin for Android:
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
At some point you have used your distribution provided
qmake
which is for Qt 4. You should re-check the commands you used and ensure you are calling your Qt 5.10.1qmake
. -
Hi, thanks for the answer. The wrong qmake is called in the line
qtVersion=$(qmake -query QT_VERSION)
I fixed it to
qtVersion=$qmake -query QT_VERSION
but the value is never used later, so i get the same errors.
I still get:~/sqlplugin ~/sqlplugin/qtbase-everywhere-src-5.10.1/src/plugins/sqldrivers/mysql ~/sqlplugin Project ERROR: Library 'mysql' is not defined. make: *** No targets specified and no makefile found. Stop.
Is there any additional library i have to point to, to make qmake accept mysql?
-
Since your configure call didn't find the libraries, they won't get built later.
-
@SGaist said in Building Qt 5.10.1 MySQL Plugin for Android:
Since your configure call didn't find the libraries, they won't get built later.
Yeah, that's my problem. I explicitly pass the libs libmariadbclient.a, libssl.a, libcrypto.a and libiconv.a to the qmake call, but it seems to miss something else. Is there a way to figure out which dependency for MySql is missing?
-
Add the
-v
option to get some more information about what is happening.