简体   繁体   English

Qt 5:共享库和静态库

[英]Qt 5: shared and static libraries

From this documentation it is not clear whether it is possible to build an executable that uses shared libraries once Qt (> 5.0) has been rebuilt in static mode. 从本文档中还不清楚,一旦以静态模式重建Qt(> 5.0),是否可以构建使用共享库的可执行文件。

I need to build both executables that use shared libraries and executables which are usable without them. 我需要构建使用共享库的可执行文件和没有共享库就可以使用的可执行文件。 Do I need to have two separate installations of Qt for that, or is it possible to use a flag to specify the desired behaviour? 为此,我是否需要安装两个单独的Qt,还是可以使用标志来指定所需的行为?

Is it possible to configure QtCreator for this purpose? 是否可以为此配置QtCreator?

Platform: Windows 7, MinGW32/GCC 4.8 平台:Windows 7,MinGW32 / GCC 4.8

I am currently using Qt on Windows 7 in the (almost) exact configuration as you described. 正如您所描述的,我目前在Windows 7(几乎)完全配置中使用Qt。 Only thing is that you will have to create 2 different compilation Kits for each purpose. 唯一的是,您将必须为每个目的创建2个不同的编译套件。

For static compile I have mingw32 compiler and for shared compile I have MSVC2010 32 bit SDK. 对于静态编译,我具有mingw32编译器,对于共享编译,我具有MSVC2010 32位SDK。

EDIT: Yes I have a statically built version of Qt 4.8.4 (qmake) and I have a Qt 5.0.0 MSVC2010 32bit (SDK) (normally built). 编辑:是的,我有一个Qt 4.8.4(qmake)的静态生成版本,我有一个Qt 5.0.0 MSVC2010 32bit(SDK)(正常生成)。 I have created 2 separate 'Kits' using these two versions and having different compilers as mentioned. 我使用这两个版本创建了2个单独的“工具包”,并且具有上述的不同编译器。 You need to include the following line to the .pro file. 您需要在.pro文件中包括以下行。 It gets ignored during shared build. 在共享构建过程中它将被忽略。

#CONFIG += staticlib 

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

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