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

Qt Dependencies issues



  • I have a main project that is reliant on a library that I am writing.

    When I start up Qt, I load the main project and usually the library. I have to remember to go in on the main projects Dependencies tab of the project and check the library. If I don't, and I make changes to the library, the compile will forget to recompile the library when it changes.

    My question is, how do I make the main project permanently remember to compile the library when it changes?

    Here's how the library gets included in my main project:

    @win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/release/ -lUnderworld
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/debug/ -lUnderworld
    else:unix: LIBS += -L$$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/ -lUnderworld

    INCLUDEPATH += $$PWD/../Underworld
    DEPENDPATH += $$PWD/../Underworld

    win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/release/libUnderworld.a
    else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/debug/libUnderworld.a
    else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/release/Underworld.lib
    else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/debug/Underworld.lib
    else:unix: PRE_TARGETDEPS += $$PWD/../build-Underworld-Desktop_Qt_5_2_1_clang_64bit-Debug/libUnderworld.a@

    I would have figured the lines:

    @INCLUDEPATH += $$PWD/../Underworld
    DEPENDPATH += $$PWD/../Underworld@

    would have done the trick. But nope.



  • I use sessions for this via Qt Creator. The session lets you remember settings like dependencies.


  • Moderators

    As far as I know, the order of projects you specify in the SUBDIRS template of .pro file is important (I assume you are using SUBDIRS, but am not sure). This means that you should place your library dir name before your application's. Feel free to check out my "spdr":https://github.com/sierdzio/spdr/blob/master/spdr.pro for a live example.



  • sierdzio,
    Your solution seems to be the one I am most familiar with. It appears promising. But I still have a fundamental problem.

    I have a main project (Lotus) and a library (Underworld). My new top level .pro file looks like this now:

    @TEMPLATE = subdirs

    SUBDIRS += ../Underworld ../Lotus
    @

    In creator, it appears like I have two sub-projects under a workspace. This reminds me a lot of workspaces in XCode.

    I can edit the code in Lotus, recompile and everything is good.

    But when I edit the library Underworld, it appears to compile the changes. But when my program (Lotus) starts running, none of my changes are coming through from the Underworld.

    What else am I missing here? This is exactly the same problem I was having before. But before I could check the dependencies and it would compile fine.


  • Moderators

    I suspect you have a deployment problem. The Release/Debug output directory contains some old DLL or SO file, and that is why you are not seeing the changes. You need to ensure that every time your application is compiled, it will take the newest version of your library.

    In my case, I use "this":https://github.com/sierdzio/spdr/blob/master/libraryIncludes.pri. It works when launching app through Qt Creator, but for running outside of QtC, I need to do manual deployment (as outlined in the documentation).


Log in to reply