Included external libraries dependending on each other



  • Hi,

    I have a convenience problem I would like to solve.

    I have developed few common libraries I typically re-use in my projects. I can include them using this kind of code in the *.pro files:

    @
    #libACBase
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../libs/libACBase/release/ -llibACBase
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../libs/libACBase/debug/ -llibACBase
    else:unix: LIBS += -L$$PWD/../../libs/libACBase/ -llibACBase

    INCLUDEPATH += $$PWD/../../libs/libACBase
    DEPENDPATH += $$PWD/../../libs/libACBase
    @

    Now the problem arises when I have another external library that depends on another external library. Even if both are included in the above manner in the project the app fails to run because (as I have found out) the external plugin cannot find its dependency even though it is in fact included in the project.

    The only solution I have right now is to manually copy all libraries to the runtime directory.

    Another option would probably be to use of "make install" (that I use for runtime plugins already).

    But is there a way to expose all included libraries to each other except for copying them in the runtime directory?



  • Thanks.

    I have solved the issue by realizing I have been doing it partly wrong.

    This part:

    @
    INCLUDEPATH += $$PWD/../../libs/libACBase
    DEPENDPATH += $$PWD/../../libs/libACBase
    @

    is correct because it is used for compiling the library and resolving its dependencies during compilation and for coding in Qt Creator.

    This part is wrong:

    @
    #libACBase
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../libs/libACBase/release/ -llibACBase
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../libs/libACBase/debug/ -llibACBase
    else:unix: LIBS += -L$$PWD/../../libs/libACBase/ -llibACBase
    @

    because the path specified is relative to the library while it should be relative to the application!

    The second code is used for dynamic runtime loading of the library and it looks for it using the specified relative path from of the output directory of the build tree.

    There are few options how to go about this:

    1. Include it both in the app that loads the library and in the library itself with proper path relative to app.
    2. Include it only in the library with path relative to the app.
    3. Use absolute path (I would not recommend it though for obvious reasons)
    4. Include it only in the library without any path at all and installing all the dependencies in the output directory.

    Maybe there are some other ways how to go about this but the bottom line is that the path specified to load the dependencies on runtime must be relative to the output directory of the app loading your library (and its dependencies) and NOT to the library location.


Log in to reply
 

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