Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Building Qt 5.10.1 MySQL Plugin for Android
Forum Updated to NodeBB v4.3 + New Features

Building Qt 5.10.1 MySQL Plugin for Android

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
7 Posts 3 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PsAePr
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.1 qmake.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PsAePr
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Since your configure call didn't find the libraries, they won't get built later.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PsAePr
            wrote on last edited by
            #5

            @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?

            C 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Add the -v option to get some more information about what is happening.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • P PsAePr

                @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?

                C Offline
                C Offline
                cawlfj
                wrote on last edited by
                #7

                @PsAePr
                Do you get success on this?
                I am stacked on it long time.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved