Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Unable to build MySQL plugin
Forum Update on Monday, May 27th 2025

Unable to build MySQL plugin

Scheduled Pinned Locked Moved Solved Mobile and Embedded
mysqlandroidsql
16 Posts 7 Posters 7.5k Views
  • 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.
  • M Offline
    M Offline
    mbnoimi
    wrote on last edited by mbnoimi
    #1

    Hi,

    Following this wiki page I tried to build MySQL plugin but unfortunately I failed because of this error message:

    /home/mbnoimi/Snippets/Scripts/Shell/create-mysql-qt-android-plugin/mariadb_client-2.0.0-src/libmariadb/my_auth.c:609:3: note: in expansion of macro 'compile_time_assert'
       compile_time_assert(CR_ERROR == 0);
       ^
    [ 50%] Building C object libmariadb/CMakeFiles/libmariadb.dir/ma_secure.c.o
    Linking C shared library libmariadb.so
    CMakeFiles/libmariadb.dir/mf_pack.c.o:mf_pack.c:function unpack_dirname: error: undefined reference to 'endpwent'
    collect2: error: ld returned 1 exit status
    make[2]: *** [libmariadb/libmariadb.so] Error 1
    make[1]: *** [libmariadb/CMakeFiles/libmariadb.dir/all] Error 2
    make: *** [all] Error 2
    Changes:
    diff: ./rootfs_files_before.txt: No such file or directory
    mbnoimi@mbnoimi-laptop ~/Snippets/Scripts/Shell/create-mysql-qt-android-plugin $ 
    
    

    I tried to use mariadb connector-c but I got this error message:

    /home/mbnoimi/Snippets/Scripts/Shell/create-mysql-qt-android-plugin/mariadb-connector-c-2.3.0-src/libmariadb/my_context.c: In function 'my_context_init':
    /home/mbnoimi/Snippets/Scripts/Shell/create-mysql-qt-android-plugin/mariadb-connector-c-2.3.0-src/libmariadb/my_context.c:129:11: error: missing binary operator before token "("
     #if sizeof(char *) > SIZEOF_INT*2
               ^
    make[2]: *** [libmariadb/CMakeFiles/mariadb_obj.dir/my_context.c.o] Error 1
    make[1]: *** [libmariadb/CMakeFiles/mariadb_obj.dir/all] Error 2
    make: *** [all] Error 2
    Changes:
    diff: ./rootfs_files_before.txt: No such file or directory
    mbnoimi@mbnoimi-laptop ~/Snippets/Scripts/Shell/create-mysql-qt-android-plugin $
    
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbnoimi
      wrote on last edited by
      #2
      • 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
      
      1 Reply Last reply
      0
      • M Offline
        M Offline
        mbnoimi
        wrote on last edited by
        #3

        Any help guys?

        L 1 Reply Last reply
        0
        • R Offline
          R Offline
          RazZziel
          wrote on last edited by RazZziel
          #4

          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

          1 Reply Last reply
          0
          • M mbnoimi

            Any help guys?

            L Offline
            L Offline
            loogicalrobo
            wrote on last edited by
            #5

            @mbnoimi.. i am suffering in same problem so would you have any idea how to solved that probelm

            M 1 Reply Last reply
            0
            • L loogicalrobo

              @mbnoimi.. i am suffering in same problem so would you have any idea how to solved that probelm

              M Offline
              M Offline
              mbnoimi
              wrote on last edited by
              #6

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

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

                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.

                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
                2
                • A Offline
                  A Offline
                  aykutozdemir
                  wrote on last edited by
                  #8

                  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"

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

                    Thanks for sharing !

                    Out of curiosity, why sudo ?

                    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
                    • A aykutozdemir

                      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"

                      M Offline
                      M Offline
                      mbnoimi
                      wrote on last edited by
                      #10

                      @aykutozdemir

                      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 $ 
                      
                      A 1 Reply Last reply
                      0
                      • M mbnoimi

                        @aykutozdemir

                        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 $ 
                        
                        A Offline
                        A Offline
                        aykutozdemir
                        wrote on last edited by aykutozdemir
                        #11

                        @mbnoimi

                        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.

                        @SGaist

                        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.

                        M 1 Reply Last reply
                        1
                        • A aykutozdemir

                          @mbnoimi

                          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.

                          @SGaist

                          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.

                          M Offline
                          M Offline
                          mbnoimi
                          wrote on last edited by
                          #12

                          @aykutozdemir said in Unable to build MySQL plugin:

                          @mbnoimi

                          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
                          
                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            aykutozdemir
                            wrote on last edited by
                            #13

                            @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.pro

                            Thank you for this too, i'm adding these lines to the script.

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SherSPB
                              wrote on last edited by SherSPB
                              #14

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

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SherSPB
                                wrote on last edited by
                                #15

                                anyone can compile MySql for different platforms from 17 to 26 for Qt 5.8 and publish them as an archive

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  Allerknappe
                                  wrote on last edited by
                                  #16

                                  can i export this script to windows and use it there?

                                  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