Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically rebuild dependencies in Qt Creator

Qt Creator (4.6.1) is driving me nuts. My application is split into 3 parts:

  • the app
  • the library
  • a unit tests app

When I change a file within the library and rebuild the application, the compiler does not recompile the library but links with the old version of the library.

Also, when I change the library, recompile it and then compile the app, no compilation takes place because it uses the cached app.

Is there a setting to change that? Here's my project file:

TEMPLATE = subdirs

SUBDIRS += \
    app \
    lib_mylib \
    tests

app.depends = lib_mylib
tests.depends = lib_mylib

The lib is built as a static library:

TEMPLATE = lib
TARGET = mylib
CONFIG += staticlib
like image 599
Georg Schölly Avatar asked Jun 12 '18 11:06

Georg Schölly


2 Answers

I have used CONFIG += ordered, DEPENDPATH and PRE_TARGETDEPS to get rid of the same problems. It works for me on linux and on win with MSVC. Try it.

in your project pro file add:

CONFIG += ordered

P.S.: your lib should be listed first. Like :

SUBDIRS += \
    lib \
    app \
    tests

in your exe .pro file add this with correct paths:

DEPENDPATH += $$PWD/../lib
PRE_TARGETDEPS += $$OUT_PWD/../lib/liblib.a

More options and flags is to be found here

like image 115
Xplatforms Avatar answered Oct 04 '22 17:10

Xplatforms


Regardless the long and understandable explanation I've tried with

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS += \
    dynamiclib \
    staticlib \
    testlibs

for my rather small and short project and it worked for me.

like image 35
Agguro Avatar answered Oct 04 '22 16:10

Agguro