简体   繁体   English

如何在Qt 5.2中使用静态库?

[英]How to use static library in Qt 5.2?

I downloaded qt recently. 我最近下载了qt。

I want to create an standalone exe, but I don't know what can I do. 我想创建一个独立的exe,但我不知道我能做什么。

In Qt5.2, the folder "(Qt)\\lib" is exists, but i can't use it in Qt Creator. 在Qt5.2中,文件夹“(Qt)\\ lib”存在,但我不能在Qt Creator中使用它。

So, should I build from source, or configure Qt Creator and use the "lib***.a"? 那么,我应该从源代码构建,还是配置Qt Creator并使用“lib ***。a”?

Any ideas? 有任何想法吗?

Environment: MinGW-32 4.8.1(TDM) / Windows 7 环境: MinGW-32 4.8.1(TDM)/ Windows 7

You seem to have tried CONFIG+=static , but that is not meant for this use case. 您似乎尝试过CONFIG+=static ,但这并不适用于此用例。 That is used when you would like to use build your library to be static after the end of the build. 这是用来当你想用建立图书馆是构建结束后静态的。

This is not the case here because you already have static Qt libraries available, so what you wish instead, to link those statically against your executable. 这不是这里的情况,因为您已经有可用的静态Qt库,所以您希望将这些库静态链接到您的可执行文件。

You would need to use this in your qmake project file: 您需要在qmake项目文件中使用它:

LIBS += -L/path/to/the/static/QtCore -lQtCore

You could also use, albeit this would make the build-system less portable across different platforms: 您也可以使用,虽然这会使构建系统在不同平台上的可移植性降低:

LIBS += /path/to/the/statis/QtCore/libQtCore.a

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

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