How to use shared library in QT android 5.2 beta
-
Hi,
I created an application in QT for android 5.1 that worked really nice. I have now installed 5.2 beta and can't get the application to work. The problem I am having is with shared libraries.To test I created a simple application composed of two projects, a simple gui app and a shared library containing a single function that returns a text.
TEMPLATE = subdirs
SUBDIRS += SharedLibTest/SharedLibTest.pro
SharedLib/SharedLib.pro \SharedLibTest is the gui app containing a button and a label, when the label is pressed it should load the SharedLib library, call the function and display the text in the label
The application compiles without errors but when deploying to an android device or emulator I see that in the build dir android/libs/armeabi-v7a folder there is no shared library libSharedLib.so which causes the app to fail of course!
How do I get creator to add my libSharedLib.so in the android/libs/armeabi-v7a directory? In the projects/run deploy config the additional libraries add is disabled. Below is my SharedLibTest project file
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = SharedLibTest
TEMPLATE = app
SOURCES += main.cpp
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
CONFIG += mobility
MOBILITY =
INCLUDEPATH += ../SharedLib
LIBS+= -L../SharedLib -lSharedLibWhat am I doing wrong so that the build libSharedLib.so file is not included in the android/libs/armeabi-v7a directory? Copying the file in the android/libs dir as well as messing with the res/values/libs.xml no longer works because creator deletes it every time.
It probably something very stupid but I am a real newbie when it comes to QT project files, anyone can help?
regards,
Luc
-
I don't know the best way to solve this problem.
But regarding the android/libs and res/values dirs (and others), from Qt 5.2 in the qmake you can specify something like:ANDROID_PACKAGE_SOURCE_DIR = $$PWD/Android_Bundle
and it copy automatically everything is there regardings the android dir and whatever is missing it copy the default ones.
So, for example, in my project, I put into Android_Bundle various directory regarding new setup about res/values/strings.xml and libs.xml, and also other things.
Maybe, you can also add a libs directory and put there your libs.
-
Thanks for pointing me in the right direction. I was able to fix it using
ANDROID_EXTRA_LIBS = ...
Still I think that library is given in LIBS += ..., the deploy tool should automatically copy it!
-
oh,it's great!
I find this sloves in here,