9

Have a SomeLib.pro file that contains:

CONFIG  += debug
TEMPLATE = lib
TARGET = SomeLib
..

Then in a dependent SomeApp.pro:

..
debug:LIBS += -lSomeLib_debug
..

How can I force SomeApp to build if I touched SomeLib in qmake?

1
  • 1
    I'm making use of qtcreator. Thus I was hoping for a solution in a .pro file. Apr 23, 2009 at 13:17

6 Answers 6

16

It's ugly because you need to give the exact library file name, but this should work:

TARGETDEPS += libfoo.a

2
  • 1
    Use PRE_TARGETDEPS instead. Feb 13, 2013 at 16:34
  • 3
    That's not ugly - implicitly prepending lib to everything is ugly - libzlib anyone?
    – Timmmm
    Jul 15, 2015 at 17:49
3

QT Creator will do the work if you click "Add library..." in the context menu of the project that should include the library.

These variables are configured automatically for you:

  • LIBS
  • INCLUDEPATH
  • DEPENDPATH
  • PRE_TARGETDEPS

See also http://doc.qt.digia.com/qtcreator-2.1/creator-project-qmake-libraries.html

2

In reply to Zahir's comment, it's perhaps worth pointing out that stating this dependency in qmake files is unnecessary if using DLLs, but is essential if your exe depends on a static library.

1

qmake does not provide this ability.

Instead, put your app and lib in subdirectories, then create a Makefile in their parent directory that looks something like this:

all: FRC
    cd Somelib && qmake && $(MAKE) 
    cd SomeApp && qmake && $(MAKE)

FRC:

Then always run make from this directory.

1
  • 1
    I'm making use of qtcreator. Thus I was hoping for a solution in a .pro file. Apr 23, 2009 at 13:32
1

I used:

POST_TARGETDEPS += c:/open-en/lib/win32mingw/libosal_based.a

It works, but is clumsy since it is necessary specify full path to library, which is different for every operating system/compiler.

0

surely that can't be possible, you are talking about using qmake to do a reverse dependency lookup? so what u want is for it to build app B (and any other app dependent on library A) after you've made a change to library A?

that's a bit like saying recompile all visual basic apps if vbrun300.dll is updated?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.