在 Linux 上部署 QT 应用程序 [英] Deployment of QT apps on linux

查看:49
本文介绍了在 Linux 上部署 QT 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ubuntu-14.04 操作系统中开发了 Qt 应用程序.我需要在不使用任何工具的情况下将可执行文件部署到目标系统中.你能指导我如何进行吗.任何关于它的信息对我都有用.等待您的回复.. 提前致谢..

谢谢和问候,雅利安

解决方案

部署动态链接的 Qt 应用程序:

您应该将 Qt .so 文件放在可执行文件的发布版本中.它们是 libQtCore.solibQtGui.so,可能还有您使用过的其他模块的.这些so 文件位于您安装的Qt 目录lib 文件夹或/usr/lib/i386-linux-gnu 目录中.如果你正在使用插件,你应该将它们的 so 文件放在你的二进制文件旁边一个名为 plugins 的文件夹中.如果使用图标和图像,您应该将它们的 so 文件(如 libqico.solibqsvg.so 发送到名为 imageformats 的文件夹中.>

收集所需的共享库:

如果您希望您的应用程序在裸安装的 Linux 上独立运行,您应该收集所有依赖的共享库并将它们放在您的应用程序目录中.您可以简单地通过名为 cpld 的 shell 脚本来完成.您可以轻松地将所有依赖项复制到一个文件夹中.

值得注意的是,您可以将其放在 .pro 文件中,以使动态链接器在 Linux 中运行时在与 Qt 应用程序相同的目录中查找:

unix:{# 如果您愿意,可以取消默认的 RPATHQMAKE_LFLAGS_RPATH=# 添加你自己的引用旋转以确保 $ORIGIN 进入未展开的命令行QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"}

I have developed Qt app in ubuntu-14.04 operating system . I need to deploy the executable file into target system without using any tool. Can u please guide me how I should proceed .Any information about it would be useful for me . Waiting for your reply.. Thanks in advance..

Thanks and Regards, Aryan

解决方案

Deploying a dynamically linked Qt application :

You should place Qt .so files along the release version of your executable. These are libQtCore.so, libQtGui.so and possibly the ones for other modules that you have used. These so files are in your installed Qt directory in lib folder or in the directory /usr/lib/i386-linux-gnu. If you are using plugins you should place their so files in a folder named plugins beside your binary. In case of using icons and images you should ship their so files like libqico.so and libqsvg.so in a folder named imageformats.

Gathering required shared libraries :

If you want your application to run independently on a bare installed Linux, you should gather all dependent shared libraries and put them in your application directory. You can simply do it by a shell script named cpld. You can easily copy all dependencies to a folder.

It's worthy to note that you can put this in your .pro file to cause the dynamic linker to look in the same directory as your Qt application at runtime in Linux :

unix:{
    # suppress the default RPATH if you wish
    QMAKE_LFLAGS_RPATH=
    # add your own with quoting gyrations to make sure $ORIGIN gets to the command line unexpanded
    QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
}

这篇关于在 Linux 上部署 QT 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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