Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

qmake: How to link a library twice?

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?

like image 362
B Faley Avatar asked Aug 20 '13 06:08

B Faley


1 Answers

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.

like image 144
Nikos C. Avatar answered Oct 15 '22 15:10

Nikos C.