LIBS 与 PRE_TARGETDEPS in .pro files of Qt 区别

目的

了解pro 文件配置中关于 LIBS 与 PRE_TARGETDEPS 区别

区别

LIBS:

Specifies a list of libraries to be linked into the project. 
If you use the Unix -l (library) and -L (library path) flags, qmake handles the libraries correctly on Windows (that is, passes the full path of the library to the linker). 
The library must exist for qmake to find the directory where a -l lib is located.

形式:
LIBS += -L$$OUT_PWD/../common -lcommon

目的:
指定要链接到项目中的库列表。
如果您使用 Unix -l(库)和 -L(库路径)标志,qmake 在 Windows 上正确处理库(即,将库的完整路径传递给链接器)。该库必须存在,qmake 才能找到 -l lib 所在的目录。



PRE_TARGETDEPS:

Lists libraries that the target depends on. 
Some backends, such as the generators for Visual Studio and Xcode project files, do not support this variable. 
Generally, this variable is supported internally by these build tools, and it is useful for explicitly listing dependent static libraries.

形式:
PRE_TARGETDEPS+= $$OUT_PWD/../common/libcommon.a

目的:
列出目标所依赖的库。
某些后端(例如 Visual Studio 和 Xcode 项目文件的生成器)不支持此变量。通常,这些构建工具在内部支持此变量,它对于显式列出依赖的静态库很有用。


参考

主要区别

Qt 使用 PRE_TARGETDEPS 变量来存储静态链接库的依赖关系。每次构建应用程序时,它都会强制您的库重新链接。
如果您没有指定此变量并且您更新和重建您的库,您的程序仍将使用旧库。
如果您使用静态库,您应该(几乎)始终同时使用 LIB 和 PRE_TARGETDEPS.

pro 变量配置
add library

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

道阻且长,行则降至

无聊,打赏求刺激而已

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值