Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Compile library and link active project when library code changes



  • Hi,

    i have 2 qmake projects. One is the main application and one is a library.

    Now i want to get the library recompiled AND relinked with my main application when a file inside the library has changed.

    Somehow i always need to manually build the lib, then pseudo change a file in my main application (to trigger new linkage) to get the changes take effect.

    There must be a way to define the dependency between my main application and my lib, but how?

    Thank's for your help, and stay healthy...

    Nando


  • Lifetime Qt Champion

    Hi
    You can use a subdir setup
    https://wiki.qt.io/SUBDIRS_-_handling_dependencies

    Stay healthy too! :)



  • @mrjj Thank you.
    I now tried it with SUBDIR like in the link.

    My folder structure is as following:

    application/
    application/application.pro
    application/src/lib/lib.pro
    application/src/main-application/main-application.pro

    And in the application.pro i set it up with SUBDIRS and .depends like this:

    TEMPLATE = subdirs
     
    SUBDIRS = \          
            lib \
            main-application
    
    lib.subdir     = src/lib
    main-application.subdir = src/main-application
    
    main-application.depends = lib
    

    Everything compiles fine.

    But now the problem remains.
    If i only change somethin inside lib and then rebuild only the lib get rebuild.
    I want that after rebuilding the lib the main-application also gets linked against the new lib... Any ideas how to solve this?



  • @Nando You have to put:

    PRE_TARGETDEPS += \
       $$PWD/../src/lib/libyourlib.a
    

    in your apllication/application.pro file.


Log in to reply