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-
x86_64/bin/arm-linux-androideabi-@I have QT for android installed in
/home/ltherriault/Qt/5.4/And I have qtbase source in :
/home/ltherriault/Tools/qtbase-opensource-src-5.4.0/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 :
@PKG_CONFIG_PATH=$SR/usr/lib/pkgconfig cmake -DCMAKE_AR="$BR"ar-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER="$BR"gcc -DCMAKE_C_FLAGS=--sysroot=$SR-DCMAKE_INSTALL_PREFIX=$SR/usr -DCMAKE_LINKER="$BR"ld -DCMAKE_NM="$BR"nm-DCMAKE_OBJCOPY="$BR"objcopy -DCMAKE_OBJDUMP="$BR"objdump -DCMAKE_RANLIB="$BR"ranlib-DCMAKE_STRIP="$BR"strip -DWITH_EXTERNAL_ZLIB=ON -DICONV_INCLUDE_DIR=$SR/usr/include-DICONV_LIBRARIES=$SR/usr/lib/libiconv.a -DZLIB_INCLUDE_DIR=$SR/usr/include-DZLIB_LIBRARY=$SR/usr/lib/libz.so ../@
Put this :
@#ifndef ushort
#define ushort uint16
endif@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/
libmariadb.so
libmariadb.so.2
libmysql.so
libmysqlclient.a
libmysqlclient.so
libmysqlclient_r.soFor 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/mysql.pro 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 libqsqlmysql.so (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");
db.setHostName(adresse);
db.setDatabaseName(bd);
db.setUserName(user);
db.setPassword(mp);
bool ok = db.open();
if (!ok)
{
QMessageBox* msg = new QMessageBox();
msg->setWindowTitle("Connexion à la base de données MYSQL");
msg->setText(db.lastError().text());
msg->show();
//Log(TYPELOG::SYSERROR, "Connexion error");
QMessageBox::critical(0, QObject::tr("Database Error"), db.lastError().text());
return;
}@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!