简体   繁体   English

qmake:如何连接两次图书馆?

[英]qmake: How to link a library twice?

I need to link the libA.a library in my qmake file twice: 我需要的链接libA.a库在我qmake文件两次:

LIBS = -lA \
       -lB \
       -lA \
       -lC \
       -lD

but qmake is removing the first -lA while running g++ . qmake正在运行g++时删除第一个-lA What should I do? 我该怎么办?

Tell qmake to disable merging of all LIBS flags with: 告诉qmake禁用所有LIBS标志的合并:

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; 或者,您可以欺骗qmake,以便它找不到重复的库; 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 . 注意-lA-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. 这确保了qmake没有看到这些标志相等,即使从编译器的角度来看,它们是相同的,因为编译器执行实际的命令行参数解析而qmake没有。

What about : 关于什么 :

QMAKE_LFLAGS += -( -lA -lB -)

?

Edit: did you try 编辑:你试过吗?

QMAKE_LFLAGS += -( -lA -lB -lC -lD -)

What this syntax does is that it will resolve all the depencies between the libraries, even if they are somewhat recursive (A::stuff needs B::stuff needs C::stuff needs A::stuff) 这个语法的作用是它将解决库之间的所有依赖关系,即使它们有点递归(A :: stuff需要B :: stuff需要C :: stuff需要A :: stuff)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM