Important: Please read the Qt Code of Conduct -

Making MySql Android plugin work for QT 5.4?

  • Hi,
    I am trying to compile a mysql plugin for QT 5.4 for Android arm7. I am on linux manjaro and I have QT 5.4 installed and I want to compile my plugin for the android level 21 to be able to use it on Android 5.0 lolipop on a nvidia shield tablet. I also want to use the toolchains v4.9. I am a little new with compiling plugin and I can't make it to work. I would like to know if someone have any idea why it is not working. Here what I am doing :
    My environment variables are :
    @$SR = /home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm
    $BR = /home/ltherriault/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-

    I have QT for android installed in

    And I have qtbase source in :

    I downloaded and compiled libiconv-1.14 with this command :
    @STRIP="$BR"strip RANLIB="$BR"ranlib OBJDUMP="$BR"objdump AR="$BR"ar CC="$BR"gcc CFLAGS=--sysroot=$SR CPP="$BR"cpp CPPFLAGS=$CFLAGS ./configure --build=x86_64 --host=arm --prefix=$SR/usr --with-sysroot=$SR && make install

    I downloaded and compiled and compiled mariadb_client-2.0.0-src with this command :


    Put this :

    @#ifndef ushort
    #define ushort uint16

    in «  include/my_global.h » before doing make install

    Now I have in /home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/mariadb/

    For doing my QtMySqlPlugin I do the following command :

    @/home/ltherriault/Qt/5.4/android_armv7/bin/qmake /home/ltherriault/Tools/qtbase-opensource-src-5.4.0/src/plugins/sqldrivers/mysql/ INCLUDEPATH+="/home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm/usr/include/mariadb/ /home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm/usr/include/" LIBPATH+="/home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/ /home/ltherriault/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/mariadb/" LIBS+="-lmysqlclient -liconv"@

    and after


    What I found weird is ithat n the output of make, it is using toolchain 4.8 and not 4.9 :

    @home/ltherriault/android-ndk-r10d/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

    -I../../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/include -I../../../../android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I../../../../android-ndk-r10d/platforms/android-21/arch-arm/usr/include -I. -o .obj/main.o ../../../qtbase-opensource-src-5.4.0/src/plugins/sqldrivers/mysql/main.cpp@

    and I don'T know why in some place I see android-9 in the output :

    @/home/ltherriault/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++ --sysroot=/home/ltherriault/android-ndk-
    L/opt/android/ndk/platforms/android-9/arch-arm//usr/lib -lQt5Core -lgnustl_shared -llog -lz -lm -ldl -lc -lgcc @

    After I am doing this command, I have (66.4 kio) in /plugins/sqldrivers/. I copie this file in /home/ltherriault/Qt/5.4/android_armv7/plugins/sqldrivers/.

    I made a small test application with this code that I deploy on my Android Nvidia shield tablet, but I always get the error « Driver not loaded Driver not loaded »

    @QSqlDatabase db;
    db = QSqlDatabase::addDatabase("QMYSQL", "main");
    bool ok =;
    if (!ok)
    QMessageBox* msg = new QMessageBox();
    msg->setWindowTitle("Connexion à la base de données MYSQL");
    //Log(TYPELOG::SYSERROR, "Connexion error");
    QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());

    Is it possible to make this plugin to work? Am I doing something wrong? Is the fact that Qmake is using toolchain 4.8 instead of 4.9 in the final step can make my plugin not working?How I can tell Qmake in the final step to not using toolchain 4.8, but 4.9? Does I have something special to do in Qt Creator to make my plugin deployed correctly to my Android Shield Tablet?

    Thank you in advance!

Log in to reply