PDA

View Full Version : I finally figured out how to do library dependencies.



sadastronaut
26th March 2008, 20:03
I had posted a couple of questions on how to have an application in one directory, qttest, depend upon a static library in another directory, qtshared. I wanted it so that whenever any source code changes in qtshared, whenever I build qttest, it would be smart enough to rebuild qtshared and relink qttest against it.

First of all, I used a .pro file in an upper level directory (the dir right above qttest and qtshared) so that it would build qtshared and qttest.
This is my .pro file in the upper dir:
################################################## ##
TEMPLATE = subdirs
SUBDIRS = qt_shared qt_test
qt_shared.file = qtshared/qtshared.pro
qt_test.file = qttest/qttest.pro
qt_test.target = QtTest
################################################## ##
However, this still wasn't good enough, because whenever I changed qtshared, it would recompile qtshared but not qttest.

However, in the .pro file in the subdir qttest, I added the line:
PRE_TARGETDEPS += ../qtshared/libqtshared.a.

By doing this, even if I only try to make QtTest in the upper level directory, it is smart enough to go to qtshared, make that static library, then go to qttest and make that application.


Sorry if this is obvious or old news, just in my short time on the forum it seemed people were trying to figure out how to do this. I hope this helps someone.

sadastronaut
26th March 2008, 22:37
One other thing. If I want to build individual targets, like QtTest, I should add:
qt_test.depends = qt_shared

Otherwise I have to build everything.