简体   繁体   English

确定 Qt 库链接

[英]Determine Qt libraries linkage

I'm trying to guess Qt's libraries linkage in a project (.pro) file.我试图在项目 (.pro) 文件中猜测 Qt 的库链接。 I'm using various Qt framework directories: 32 and 64 bit Windows, Linux and Android builds;我正在使用各种 Qt 框架目录:32 位和 64 位 Windows、Linux 和 Android 版本; using static and shared Qt libraries.使用静态和共享 Qt 库。 I've tried several way to check Qt's linkage, but nothing has worked so far.我尝试了几种方法来检查 Qt 的链接,但到目前为止没有任何效果。

Try 1:尝试 1:

qtConfig(static): message("Qt statically linked") qtConfig(static): message("Qt 静态链接")

Try 2:尝试2:

CONFIG(static, static|shared): message("Qt statically linked") CONFIG(静态,静态|共享):消息(“Qt静态链接”)

Try 3:尝试3:

static: message("Qt statically linked")静态:消息(“Qt静态链接”)

I guessed all previous test would lead the same result, and thus show the "message" when selected Qt build is a static one, but I don't know if it's a Qt Creator issue or if I'm overriding *CONFIG variables in project tree.我猜所有以前的测试都会带来相同的结果,从而显示所选择的QT构建时的“消息”是一个静态的结果,但我不知道它是否是Qt Creator问题,或者我是否覆盖项目中的*CONFIG变量树。 I've checked it out too many times over and I haven't found any problem with that.我已经检查过很多次了,我没有发现任何问题。

There's no such Qt-config feature as "static".没有像“静态”这样的 Qt-config 功能。 So the right one is所以正确的是

!qtConfig(shared): message("Qt statically linked")

As an alternative you can do作为替代方案,您可以这样做

!contains(QT.global.enabled_features, shared): message("Qt statically linked")

But this one is even less documented, so you're better to stick with qtConfig() which essentially tests for the same thing.但是这个文档的记录更少,所以你最好坚持使用qtConfig() ,它基本上测试相同的东西。

No. 2 is a test of a build configuration of the user project itself, ie if you're building a static or shared library of your own .第 2 项是对用户项目本身的构建配置的测试,即,如果您正在构建您自己的静态或共享库。

No. 3 is a wrong way to do No. 2, because user's CONFIG is allowed to contain both shared/static, debug/release etc. at the same time. 3号是一个错误的方式做2号,因为用户的CONFIG允许包含两个共享/静态,调试/在同一时间发布等。 And only the last one will matter.而只有最后一个才是重要的。

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

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