qmake SUBDIRS and Qt libraries dependencies



  • Hi!

    I have quite complex project divided on libraries.
    In qmake file I'm using SUBDIRS template, more-less like this:

    SUBDIRS = src/lib1\
              src/lib2\
              src/main\
    

    In main there are files for android build and I'm adding the libraries with the following statement:

    ANDROID_EXTRA_LIBS += $$OUT_PWD/lib1.so\
                            $$OUT_PWD/lib2.so\
    

    All works fine, Android apk is built correctly.

    The problem occurs when some library, i.e. lib1 depends on Qt module that main application library doesn't.
    Concretely, lib1 uses QtNetwork mod but main doesn't
    In that case the application crashes during launch due to unable to load QtNetwork lib (even if I'm trying to add it with ANDROID_EXTRA_LIBS and apk contains it).
    My workaround for it is to add some dummy method in main (never called) that uses something from QtNetwork mod. This way all works.

    So, is there any better way ?


  • Qt Champions 2016

    @SeeLook
    Hi,
    Take a look here it should be helpful for your case. Just add the appropriate modules to each of the targets and set the targets' dependencies appropriately.

    Kind regards.



  • @kshegunov
    Thank You for the answer and sorry for my late response....

    SUBDIRS documentation was quite interesting but a solution is rather not there.
    To properly load all dependencies during launching under Android, the apk has to have the list of them and androiddeployqt is responsible for that.
    I dig its doc and found ANDROID_DEPLOYMENT_DEPENDENCIES variable which can overwrite the list of libs automatically detected by androiddeployqt but I have to take responsibility to put there all dependencies in proper order.
    I will try so...

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.