在 OS X 和 Linux 上部署 QT 应用程序
部署 QT 应用程序的最佳方式是什么?我已阅读 trolltech 托管的文档,但是链接静态库还是动态库并让用户安装框架更好?我真的不希望使用我的应用程序的任何人都必须下载 160mb 的框架才能运行简单的 GUI 前端。
Whats the best way to deploy a QT app? I've read the documentation hosted at trolltech but is it better to link with a static library or the dynamic libraries and have the user install the framework? I don't really want anyone using my app to have to download a 160mb framework just to run a simple gui frontend.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 OS X 上,这是使用 Qt 从 4.5 开始附带的
macdeployqt
工具进行动态构建和后处理生成的“.app”的好方法。这会将应用程序使用的 Qt 框架复制到应用程序包中,从而生成比构建应用程序的静态版本更大的包。
您可以采取以下措施来确保在动态构建中获得尽可能小的文件大小:
QT += core gui network xml中)
行)。macdeployqt
自动编译其中的所有 Qt 插件,这可能有点庞大。除此之外,您应该使用压缩磁盘映像来部署应用程序。
我的一个项目使用 QtGui、QtNetwork、QtCore 和 QtXml,生成的包大小约为 16 MB 。
希望有帮助。
On OS X it's a good way to do a dynamic build and post-process the resulting ".app" with the
macdeployqt
tool which comes with Qt starting with 4.5.This will copy the Qt frameworks used by your application into the application bundle, which results in a larger package than building a static version of your application.
Here is what you can do to make sure you get the smallest file size possibly in a dynamic build:
QT += core gui network xml
lines).macdeployqt
automatically compies all the Qt plugins in there, which can be kind of bulky.Other than that, you should use compressed disk images to deploy your application.
One of my projects uses QtGui, QtNetwork, QtCore and QtXml and the resulting bundle is about 16 MB in size.
Hope that helps.
不幸的是,您必须将所需的 Qt 库包含到您自己的捆绑包中,因为您不能指望您的用户在 Mac 上安装 Qt(而在 Linux 打包系统上允许您至少需要给定版本的 Qt。
有一个很好的解决方案一个名为 macdeployqt 的工具可以帮助您完成此任务,您只需在捆绑应用程序上调用它,它就会打包所需的库,并更改二进制文件的链接以引用它们。真正的痛苦(仍然如此,但要少得多)
。 >http://doc.trolltech.com/4.6/deployment-mac.html#the-mac-deployment-tool
然后,您可以像使用任何其他应用程序一样制作 .dmg 映像。 macdeployqt 中构建基本选项的一个选项。
Unfortunately you will have to include the Qt libraries you need into your own bundle, as you cannot expect your users to have Qt installed on Mac (whereas on Linux packaging systems allow you to require at least a given version of Qt.
There is a nice tool to help you with that, which is called macdeployqt. You just need to invoke it on your bundle application and it will pack the required libraries, changing the linkage of your binary to refer to them. Without it, making bundles for Mac is a real pain (it still is, but considerably less though).
http://doc.trolltech.com/4.6/deployment-mac.html#the-mac-deployment-tool
Afterwards, you can make a .dmg image as you would do with any other app. There is an option in macdeployqt that builds a basic one.
在 Linux 上,最好依赖操作系统的 Qt 副本,因为它几乎肯定已安装 - 对于 OS X,几乎所有应用程序都使用静态编译的库。
On Linux, it's better to rely on the OS's copy of Qt, as it's almost certainly installed - for OS X, almost all apps use a statically compiled library.