qmake: How to link a library twice?
c++, circular-dependency, qmake
Solution
Tell qmake to disable merging of all LIBS flags with:
CONFIG += no_lflags_merge
However, this will result in all duplicate libraries to not be cleaned up. This shouldn't matter in practice though.
Alternatively, you can trick qmake so that it doesn't find the duplicate libary; since it only matches strings and doesn't really parse the library flags, you can do:
LIBS += -lA -lB -l A -lC -lD
Note the difference between `-lA` and `-l A`. This makes sure that qmake doesn't see those flags as equal, even though from the compiler's point of view, they are equal, since the compiler does actual command line argument parsing while qmake does not.
Problem
I need to link the `libA.a` library in my `qmake` file twice: ``` LIBS = -lA \ -lB \ -lA \ -lC \ -lD ``` but `qmake` is removing the first `-lA` while running `g++`. What should I do?