问题描述
我是一个Qt初学者,我想知道如何使用其静态库构建Qt5应用程序。是否可以用静态库构建一切可以用DLL构建?我想知道,因为我不想在我想要我的应用程序运行的任何地方安装Qt库。例如,我想使用静态libs应用程序构建这个代码是在这篇文章:
I'm a Qt beginner and I want to know how to build Qt5 apps with their static libraries. Is that possible to build with static libs everything that can be build with dll's ?. I want to know because I don't want to install Qt libs everywhere where I want my apps to be running. For example I want to build with static libs app which code is in this post:
这是可能吗?
如何做?
Is that possible ?How to do that ?
推荐答案
为了使用Qt作为静态库,你必须重建Qt本身。
您可以在
In order to use Qt as a static library, you have to rebuild Qt itself.You can find a guide here
建议如下重建Qt:
cd C:\path\to\Qt
configure -static <any other options you need>
nmake sub-src
确保您嵌入了所有需要的插件。 (参见 configure
选项)
Make sure you've embedded all plugins you need. (see configure
options)
然而,并不是所有的Qt部分都可以构建为静态库。据我所知,您可能会对Webkit造成一些困难。
However, not all Qt parts can be built as a static libraries. As far as I know, you may expose some difficulties with Webkit.
重建Qt后,您可以照常构建您的应用程序。
After rebuilding Qt, you can build your apps, as usual.
还要注意,Qt是按照LGPL或GPL或商业许可证授权的。使用静态版本的Qt可以对您的应用程序分发施加一些限制。
Note also, that Qt is licensed under LGPL or GPL or commercial licence. Using static version of Qt can impose some limitations on your app distributions.
这篇关于如何用他们的静态库构建Qt5应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!