与Qt项目静态链接 [英] Static linking with a Qt project

查看:157
本文介绍了与Qt项目静态链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我在Visual Studio 2010 Professional中构建的Qt项目。但是,当我运行它(在调试或发布模式),它要求几个Qt DLL。它的工作原理,如果我提供的dll,并将它们扔到System32,但我的问题是,我如何使所有的库都包括在.exe中?我有所有的静态库我需要,我只是不知道如何使它,所以应用程序不询问他们的最终用户。

I've got a Qt project I've built in Visual Studio 2010 Professional. However, when I run it (in either Debug or Release mode) it asks for a few Qt dll's. It works if I supply the dll's and throw them into System32, but my question is, how do I make it so that all libraries are included in the .exe? I have all of the static libraries I need, I just don't know how to make it so that the app doesn't ask the end user for them.

推荐答案

正确的方法是创建一个安装程序,与应用程序一起安装Qt库。 Visual Studio附带一个安装项目模板,您可以轻松地使用它来创建自己的自定义安装程序。静态链接很少是一个很好的选择,很多原因。

The correct way is to create a setup program that installs the Qt libraries along with your application. Visual Studio comes with a setup project template that you can use to create your own customized installer easily. Static linking is rarely a good option, for numerous reasons.

然而,如果你坚持静态链接,你需要重新编译Qt源与 -static 标志。

可以进行演练这里用于Qt 4.

However, if you insist on static linking, you'll need to recompile the Qt sources with the -static flag.
A walkthrough is available here for Qt 4.

如果您使用的是Qt的LGPL版本,请务必阅读< a href =http://stackoverflow.com/questions/2277165/qt-single-exe-with-lgpl>此问题,并适当解决您部署的所有法律问题。

And if you're using the LGPL version of Qt, make sure you've read the answers to this question and appropriate addressed all legal concerns with your deployment.

这篇关于与Qt项目静态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆