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. How to use shared library in QT android 5.2 beta
Forum Updated to NodeBB v4.3 + New Features

How to use shared library in QT android 5.2 beta

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 6.5k Views 1 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.
  • L Offline
    L Offline
    lroels
    wrote on last edited by
    #1

    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 -lSharedLib

    What 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

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lroels
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toby520
          wrote on last edited by
          #4

          oh,it's great!
          I find this sloves in here,

          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