PDA

View Full Version : Static linking problem in Linux



daou
15th October 2009, 09:55
I have a project that consists of a couple of components, each built as a separate static library. However, when one static library is updated, the main executable is not relinked if it already exists. As a workaround, I'm currently removing the final binary file before calling make on the project.

Is there some directive I can give to the pro file to either automatically remove the binary file before compiling or force a relink if a static library has been updated since the last build?

The build system looks like this:

- project.pro (TEMPLATE = subdirs; SUBDIRS = component1, component2, main)
- component1/
--- component1.pro (TEMPLATE = lib; CONFIG += staticlib)
- component2/
--- component2.pro (TEMPLATE = lib; CONFIG += staticlib)
- main/
--- main.pro (TEMPLATE = app; LIBS += -L../component1 -L../component2 -lcomponent1 -lcomponent2)

daou
25th October 2009, 09:10
Answering my own question: by using the TARGETDEPS variable in a pro file.
ex. in build.pro "TARGETDEPS += ../component1/libcomponent1.a"